This repository has been archived by the owner on Dec 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a6f0e7
commit 7ac67a0
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
lib/clientSideScripts/__snapshots__/hideRemoveElements.spec.ts.snap
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,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`hideRemoveElements should be able to hide elements and put them back again 1`] = `""`; | ||
|
||
exports[`hideRemoveElements should be able to hide elements and put them back again 2`] = `""`; | ||
|
||
exports[`hideRemoveElements should be able to hide elements and put them back again 3`] = `"hidden"`; | ||
|
||
exports[`hideRemoveElements should be able to hide elements and put them back again 4`] = `"hidden"`; | ||
|
||
exports[`hideRemoveElements should be able to hide elements and put them back again 5`] = `""`; | ||
|
||
exports[`hideRemoveElements should be able to hide elements and put them back again 6`] = `""`; | ||
|
||
exports[`hideRemoveElements should be able to remove elements and put them back again 1`] = `""`; | ||
|
||
exports[`hideRemoveElements should be able to remove elements and put them back again 2`] = `""`; | ||
|
||
exports[`hideRemoveElements should be able to remove elements and put them back again 3`] = `"none"`; | ||
|
||
exports[`hideRemoveElements should be able to remove elements and put them back again 4`] = `"none"`; | ||
|
||
exports[`hideRemoveElements should be able to remove elements and put them back again 5`] = `""`; | ||
|
||
exports[`hideRemoveElements should be able to remove elements and put them back again 6`] = `""`; |
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,79 @@ | ||
import hideRemoveElements from './hideRemoveElements'; | ||
|
||
describe('hideRemoveElements', () => { | ||
it('should be able to hide elements and put them back again', () => { | ||
document.body.innerHTML = | ||
'<div>' + | ||
' <span id="id-1">Hello</span>' + | ||
' <span id="id-2">Hello</span>' + | ||
' <div>' + | ||
' <span id="id-3">Hello</span>' + | ||
' <span id="id-4">Hello</span>' + | ||
' </div>' + | ||
'</div>'; | ||
|
||
// Check not hidden | ||
expect((<HTMLElement>document.querySelector('#id-1')).style.visibility).toMatchSnapshot(); | ||
expect((<HTMLElement>document.querySelector('#id-3')).style.visibility).toMatchSnapshot(); | ||
|
||
hideRemoveElements({ | ||
hide: [document.querySelector('#id-1'), document.querySelector('#id-3')], | ||
remove: [], | ||
}, | ||
true, | ||
); | ||
|
||
// Check hidden | ||
expect((<HTMLElement>document.querySelector('#id-1')).style.visibility).toMatchSnapshot(); | ||
expect((<HTMLElement>document.querySelector('#id-3')).style.visibility).toMatchSnapshot(); | ||
|
||
hideRemoveElements({ | ||
hide: [document.querySelector('#id-1'), document.querySelector('#id-3')], | ||
remove: [], | ||
}, | ||
false, | ||
); | ||
|
||
// Check not hidden | ||
expect((<HTMLElement>document.querySelector('#id-1')).style.visibility).toMatchSnapshot(); | ||
expect((<HTMLElement>document.querySelector('#id-3')).style.visibility).toMatchSnapshot(); | ||
}); | ||
|
||
it('should be able to remove elements and put them back again', () => { | ||
document.body.innerHTML = | ||
'<div>' + | ||
' <span id="id-1">Hello</span>' + | ||
' <span id="id-2">Hello</span>' + | ||
' <div>' + | ||
' <span id="id-3">Hello</span>' + | ||
' <span id="id-4">Hello</span>' + | ||
' </div>' + | ||
'</div>'; | ||
|
||
// Check not removed | ||
expect((<HTMLElement>document.querySelector('#id-2')).style.display).toMatchSnapshot(); | ||
expect((<HTMLElement>document.querySelector('#id-4')).style.display).toMatchSnapshot(); | ||
|
||
hideRemoveElements({ | ||
hide: [], | ||
remove: [document.querySelector('#id-2'), document.querySelector('#id-4')], | ||
}, | ||
true, | ||
); | ||
|
||
// Check removed | ||
expect((<HTMLElement>document.querySelector('#id-2')).style.display).toMatchSnapshot(); | ||
expect((<HTMLElement>document.querySelector('#id-4')).style.display).toMatchSnapshot(); | ||
|
||
hideRemoveElements({ | ||
remove: [document.querySelector('#id-2'), document.querySelector('#id-4')], | ||
hide: [], | ||
}, | ||
false, | ||
); | ||
|
||
// Check not removed | ||
expect((<HTMLElement>document.querySelector('#id-2')).style.display).toMatchSnapshot(); | ||
expect((<HTMLElement>document.querySelector('#id-4')).style.display).toMatchSnapshot(); | ||
}); | ||
}); |