mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Migrate clipboard-action-default to functional approach. Update tests. Add tests
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
import select from 'select';
|
||||
import command from '../../src/common/command';
|
||||
|
||||
describe('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');
|
||||
@ -10,26 +11,39 @@ describe('command', () => {
|
||||
});
|
||||
|
||||
after(() => {
|
||||
global.stub.restore();
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
it('should execute cut command', (done) => {
|
||||
// Set document direction
|
||||
document.documentElement.setAttribute('dir', 'rtl');
|
||||
|
||||
it('should execute cut', (done) => {
|
||||
global.stub.returns(true);
|
||||
select(document.querySelector('#input'));
|
||||
|
||||
assert.isTrue(command('cut'));
|
||||
done();
|
||||
});
|
||||
|
||||
it('should execute copy command', (done) => {
|
||||
// Set document direction
|
||||
document.documentElement.setAttribute('dir', 'rtl');
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user