mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Add/update tests
This commit is contained in:
35
test/common/command.js
Normal file
35
test/common/command.js
Normal file
@ -0,0 +1,35 @@
|
||||
import select from 'select';
|
||||
import command from '../../src/common/command';
|
||||
|
||||
describe('command', () => {
|
||||
before(() => {
|
||||
global.input = document.createElement('input');
|
||||
global.input.setAttribute('id', 'input');
|
||||
global.input.setAttribute('value', 'abc');
|
||||
document.body.appendChild(global.input);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
it('should execute cut command', (done) => {
|
||||
// Set document direction
|
||||
document.documentElement.setAttribute('dir', 'rtl');
|
||||
|
||||
select(document.querySelector('#input'));
|
||||
|
||||
assert.isTrue(command('cut'));
|
||||
done();
|
||||
});
|
||||
|
||||
it('should execute copy command', (done) => {
|
||||
// Set document direction
|
||||
document.documentElement.setAttribute('dir', 'rtl');
|
||||
|
||||
select(document.querySelector('#input'));
|
||||
|
||||
assert.isTrue(command('copy'));
|
||||
done();
|
||||
});
|
||||
});
|
13
test/common/create-fake-element.js
Normal file
13
test/common/create-fake-element.js
Normal file
@ -0,0 +1,13 @@
|
||||
import createFakeElement from '../../src/common/create-fake-element';
|
||||
|
||||
describe('createFakeElement', () => {
|
||||
it('should define a fake element and set the position right style property', (done) => {
|
||||
// Set document direction
|
||||
document.documentElement.setAttribute('dir', 'rtl');
|
||||
|
||||
const el = createFakeElement(document.body);
|
||||
|
||||
assert.equal(el.style.right, '-9999px');
|
||||
done();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user