mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Throws error if either data-target or data-text were passed and throws error if neither data-target nor data-text were passed too
This commit is contained in:
@ -12,6 +12,31 @@ describe('ClipboardAction', () => {
|
||||
});
|
||||
|
||||
describe('#constructor', () => {
|
||||
it('should throw an error since both "data-text" and "data-target" were passed', (done) => {
|
||||
try {
|
||||
new ClipboardAction({
|
||||
text: 'foo',
|
||||
target: 'target'
|
||||
});
|
||||
}
|
||||
catch(e) {
|
||||
assert.equal(e.message, 'Multiple attributes declared, use either "data-target" or "data-text"');
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error since neither "data-text" nor "data-target" were passed', (done) => {
|
||||
try {
|
||||
new ClipboardAction({
|
||||
action: ''
|
||||
});
|
||||
}
|
||||
catch(e) {
|
||||
assert.equal(e.message, 'Missing required attributes, use either "data-target" or "data-text"');
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw an error since "data-action" is invalid', (done) => {
|
||||
try {
|
||||
new ClipboardAction({
|
||||
|
Reference in New Issue
Block a user