diff --git a/test/clipboard-action.js b/test/clipboard-action.js index 5d741a4..4f92ec3 100644 --- a/test/clipboard-action.js +++ b/test/clipboard-action.js @@ -3,14 +3,18 @@ import ClipboardAction from '../src/clipboard-action'; describe('ClipboardAction', () => { before(() => { global.target = document.createElement('input'); - target.setAttribute('id', 'foo'); + global.target.setAttribute('id', 'target'); document.body.appendChild(global.target); global.trigger = document.createElement('button'); - trigger.setAttribute('class', 'btn'); + global.trigger.setAttribute('class', 'btn'); document.body.appendChild(global.trigger); }); + after(() => { + document.body.innerHTML = ''; + }); + describe('#constructor', () => { it('should throw an error since both "data-text" and "data-target" were passed', (done) => { try { @@ -40,10 +44,12 @@ describe('ClipboardAction', () => { it('should throw an error since "data-action" is invalid', (done) => { try { new ClipboardAction({ + text: 'foo', action: 'paste' }); } catch(e) { + assert.equal(e.message, 'Invalid "data-action" value, use either "copy" or "cut"'); done(); } }); @@ -51,17 +57,13 @@ describe('ClipboardAction', () => { it('should throw an error since "data-target" do not match any element', (done) => { try { new ClipboardAction({ - target: 'zzz', - trigger: global.trigger + target: 'foo' }); } catch(e) { + assert.equal(e.message, 'Invalid "data-target" selector, use a value that matches an ID'); done(); } }); }); - - after(() => { - document.body.innerHTML = ''; - }); }); diff --git a/test/clipboard.js b/test/clipboard.js index 58ca6eb..7f36055 100644 --- a/test/clipboard.js +++ b/test/clipboard.js @@ -13,6 +13,7 @@ describe('Clipboard', () => { new Clipboard(); } catch(e) { + assert.equal(e.message, 'No matches were found for the provided selector'); done(); } }); @@ -22,6 +23,7 @@ describe('Clipboard', () => { new Clipboard('#abc'); } catch(e) { + assert.equal(e.message, 'No matches were found for the provided selector'); done(); } });