mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
![]() |
import ClipboardAction from '../src/clipboard-action';
|
||
|
|
||
|
describe('ClipboardAction', () => {
|
||
|
before(() => {
|
||
|
global.target = document.createElement('input');
|
||
|
target.setAttribute('id', 'foo');
|
||
|
document.body.appendChild(global.target);
|
||
|
|
||
|
global.trigger = document.createElement('button');
|
||
|
trigger.setAttribute('class', 'btn');
|
||
|
document.body.appendChild(global.trigger);
|
||
|
});
|
||
|
|
||
|
describe('#constructor', () => {
|
||
|
it('should throw an error since "data-action" is invalid', (done) => {
|
||
|
try {
|
||
|
new Clipboard({
|
||
|
action: 'paste'
|
||
|
});
|
||
|
}
|
||
|
catch(e) {
|
||
|
done();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
it('should throw an error since "data-target" do not match any element', (done) => {
|
||
|
try {
|
||
|
new ClipboardAction({
|
||
|
target: 'zzz',
|
||
|
trigger: global.trigger
|
||
|
});
|
||
|
}
|
||
|
catch(e) {
|
||
|
done();
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
after(() => {
|
||
|
document.body.innerHTML = '';
|
||
|
});
|
||
|
});
|