UNPKG

1.16 kBJavaScriptView Raw
1import select from 'select';
2import command from '../../src/common/command';
3
4describe('#command', () => {
5 before(() => {
6 global.stub = sinon.stub(document, 'execCommand');
7 global.input = document.createElement('input');
8 global.input.setAttribute('id', 'input');
9 global.input.setAttribute('value', 'abc');
10 document.body.appendChild(global.input);
11 });
12
13 after(() => {
14 global.stub.restore();
15 document.body.innerHTML = '';
16 });
17
18 it('should execute cut', (done) => {
19 global.stub.returns(true);
20 select(document.querySelector('#input'));
21
22 assert.isTrue(command('cut'));
23 done();
24 });
25
26 it('should execute copy', (done) => {
27 global.stub.returns(true);
28 select(document.querySelector('#input'));
29
30 assert.isTrue(command('copy'));
31 done();
32 });
33
34 it('should not execute copy', (done) => {
35 global.stub.returns(false);
36 select(document.querySelector('#input'));
37
38 assert.isFalse(command('copy'));
39 done();
40 });
41
42 it('should not execute cut', (done) => {
43 global.stub.returns(false);
44 select(document.querySelector('#input'));
45
46 assert.isFalse(command('cut'));
47 done();
48 });
49});