You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
import select from 'select';
|
|
import command from '../../src/common/command';
|
|
|
|
describe('#command', () => {
|
|
before(() => {
|
|
global.stub = sinon.stub(document, 'execCommand');
|
|
global.input = document.createElement('input');
|
|
global.input.setAttribute('id', 'input');
|
|
global.input.setAttribute('value', 'abc');
|
|
document.body.appendChild(global.input);
|
|
});
|
|
|
|
after(() => {
|
|
global.stub.restore();
|
|
document.body.innerHTML = '';
|
|
});
|
|
|
|
it('should execute cut', (done) => {
|
|
global.stub.returns(true);
|
|
select(document.querySelector('#input'));
|
|
|
|
assert.isTrue(command('cut'));
|
|
done();
|
|
});
|
|
|
|
it('should execute copy', (done) => {
|
|
global.stub.returns(true);
|
|
select(document.querySelector('#input'));
|
|
|
|
assert.isTrue(command('copy'));
|
|
done();
|
|
});
|
|
|
|
it('should not execute copy', (done) => {
|
|
global.stub.returns(false);
|
|
select(document.querySelector('#input'));
|
|
|
|
assert.isFalse(command('copy'));
|
|
done();
|
|
});
|
|
|
|
it('should not execute cut', (done) => {
|
|
global.stub.returns(false);
|
|
select(document.querySelector('#input'));
|
|
|
|
assert.isFalse(command('cut'));
|
|
done();
|
|
});
|
|
});
|
|
|