Source formatting and testing for #24

This commit is contained in:
Zeno Rocha
2015-10-03 19:04:37 -07:00
parent cc9d562580
commit 0c24503214
2 changed files with 53 additions and 1 deletions

View File

@ -69,6 +69,27 @@ describe('Clipboard', () => {
});
});
describe('#undelegateClick', function() {
before(() => {
global.spy = sinon.spy(Delegate, 'unbind');
});
after(() => {
global.spy.restore();
});
it('should undelegate a click event', () => {
let element = document.body;
let event = 'click';
let clipboard = new Clipboard('.btn');
clipboard.undelegateClick();
assert.ok(global.spy.calledOnce);
assert.ok(global.spy.calledWith(element, event));
});
});
describe('#onClick', () => {
it('should create a new instance of ClipboardAction', () => {
let clipboard = new Clipboard('.btn');
@ -92,4 +113,15 @@ describe('Clipboard', () => {
}
});
});
describe('#destroy', () => {
it('should destroy an existing instance of ClipboardAction', () => {
let clipboard = new Clipboard('.btn');
clipboard.onClick(global.event);
clipboard.destroy();
assert.equal(clipboard.clipboardAction, null);
});
});
});