forked from shipshapecode/tether
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove classes on destroy (shipshapecode#316)
Closes shipshapecode#36
- Loading branch information
1 parent
76f3ccf
commit 95bce1e
Showing
3 changed files
with
70 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Tether from '../../src/js/tether.js'; | ||
|
||
describe('Tether', () => { | ||
describe('destroy()', () => { | ||
it('removes classes on destroy', () => { | ||
const element = document.createElement('div'); | ||
element.classList.add('element'); | ||
document.body.appendChild(element); | ||
const target = document.createElement('div'); | ||
target.classList.add('target'); | ||
document.body.appendChild(target); | ||
expect(element.classList.length, 'element - only one class').toEqual(1); | ||
expect(target.classList.length, 'target - only one class').toEqual(1); | ||
const tether = new Tether({ | ||
element: '.element', | ||
target: '.target', | ||
attachment: 'top left', | ||
targetAttachment: 'top right' | ||
}); | ||
|
||
tether.enable(); | ||
|
||
expect(element.classList.length, 'element - tether classes added').toEqual(12); | ||
expect(target.classList.length, 'target - tether classes added').toEqual(12); | ||
|
||
tether.destroy(); | ||
|
||
expect(element.classList.length, 'element - destroy sets classes back to initial state').toEqual(1); | ||
expect(target.classList.length, 'target - destroy sets classes back to initial state').toEqual(1); | ||
}); | ||
}); | ||
}); |