WXL
5 天以前 871522ed7e06fd9c62a87c178d7f5c88d7853a20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import ClipboardActionCut from '../../src/actions/cut';
 
describe('ClipboardActionCut', () => {
  before(() => {
    global.input = document.createElement('input');
    global.input.setAttribute('id', 'input');
    global.input.setAttribute('value', 'abc');
    document.body.appendChild(global.input);
 
    global.paragraph = document.createElement('p');
    global.paragraph.setAttribute('id', 'paragraph');
    global.paragraph.textContent = 'abc';
    document.body.appendChild(global.paragraph);
  });
 
  after(() => {
    document.body.innerHTML = '';
  });
 
  describe('#selectText', () => {
    it('should select its value', () => {
      const selectedText = ClipboardActionCut(
        document.querySelector('#input'),
        {
          container: document.body,
        }
      );
 
      assert.equal(selectedText, document.querySelector('#input').value);
    });
  });
});