mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Adds karma test suite
This commit is contained in:
42
test/clipboard-action.js
Normal file
42
test/clipboard-action.js
Normal file
@ -0,0 +1,42 @@
|
||||
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 = '';
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user