mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Adds tests for Clipboard.validate
This commit is contained in:
parent
52b444609e
commit
cd7c8bfc27
@ -25,4 +25,46 @@ describe('Clipboard', () => {
|
||||
return assert.instanceOf(clipboard.triggers, NodeList);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#validate', () => {
|
||||
var elem = document.createElement('input');
|
||||
let clipboard = new Clipboard('.btn');
|
||||
|
||||
it('should throw an error since there was no "data-target" or "data-text"', (done) => {
|
||||
try {
|
||||
clipboard.validate({
|
||||
currentTarget: elem
|
||||
});
|
||||
}
|
||||
catch(e) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error since "data-action" is invalid', (done) => {
|
||||
try {
|
||||
elem.setAttribute('data-action', 'paste');
|
||||
|
||||
clipboard.validate({
|
||||
currentTarget: elem
|
||||
});
|
||||
}
|
||||
catch(e) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error since "data-target" do not match any element', (done) => {
|
||||
try {
|
||||
elem.setAttribute('data-target', 'xyz');
|
||||
|
||||
clipboard.validate({
|
||||
currentTarget: elem
|
||||
});
|
||||
}
|
||||
catch(e) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user