-
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.
Merge branch 'work-form-html-attribute'
- Loading branch information
Showing
12 changed files
with
149 additions
and
26 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,101 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
import { | ||
onScreenness, | ||
onScreenTest | ||
} from '../../src/onScreenness.js'; | ||
|
||
|
||
describe('An element with an onscreenness data attribute in the html will be in the assesment', function () { | ||
|
||
let trigger; | ||
let liveList; | ||
|
||
beforeAll(() => { | ||
trigger = onScreenTest.triggerEvent; | ||
liveList = onScreenTest.makeNodeList; | ||
}); | ||
|
||
beforeEach(() => { | ||
onScreenness.reset(); | ||
}); | ||
|
||
|
||
/* Test creation of live nodeLists */ | ||
|
||
test('A reset situation without onscreenness data attributes', () => { | ||
document.body.innerHTML = ` | ||
<h2>Basic Example</h2> | ||
<section> | ||
<div id="first" class="example">Basic Example Element</div> | ||
<div id="second" class="example">Basic Example Element</div> | ||
<div id="third" class="example">Basic Example Element</div> | ||
<div id="fourth" class="example">Basic Example Element</div> | ||
<div id="fifth" class="example">Basic Example Element</div> | ||
<div id="sixth" class="example">Basic Example Element</div> | ||
<div id="seventh" class="example">Basic Example Element</div> | ||
<div id="eighth" class="example">Basic Example Element</div> | ||
</section> | ||
`; | ||
let nodes = liveList(); | ||
expect(nodes.length).toBe(0); | ||
}); | ||
|
||
test('A reset situation with one onscreenness data attributes', () => { | ||
document.body.innerHTML = ` | ||
<h2>Basic Example</h2> | ||
<section> | ||
<div id="first" class="example">Basic Example Element</div> | ||
<div id="second" class="example">Basic Example Element</div> | ||
<div id="third" class="example">Basic Example Element</div> | ||
<div id="fourth" class="example" data-onscreenness>Example Element with data-onscreenness attribute</div> | ||
<div id="fifth" class="example">Basic Example Element</div> | ||
<div id="sixth" class="example">Basic Example Element</div> | ||
<div id="seventh" class="example">Basic Example Element</div> | ||
<div id="eighth" class="example">Basic Example Element</div> | ||
</section> | ||
`; | ||
let nodes = liveList(); | ||
expect(nodes.length).toBe(1); | ||
}); | ||
|
||
test('A reset situation with three onscreenness data attributes', () => { | ||
document.body.innerHTML = ` | ||
<h2>Basic Example</h2> | ||
<section> | ||
<div id="first" class="example" data-onscreenness>Example Element with data-onscreenness attribute</div> | ||
<div id="second" class="example">Basic Example Element</div> | ||
<div id="third" class="example">Basic Example Element</div> | ||
<div id="fourth" class="example" data-onscreenness>Example Element with data-onscreenness attribute</div> | ||
<div id="fifth" class="example">Basic Example Element</div> | ||
<div id="sixth" class="example">Basic Example Element</div> | ||
<div id="seventh" class="example" data-onscreenness>Example Element with data-onscreenness attribute</div> | ||
<div id="eighth" class="example">Basic Example Element</div> | ||
</section> | ||
`; | ||
let nodes = liveList(); | ||
expect(nodes.length).toBe(3); | ||
}); | ||
|
||
test('A reset situation with three onscreenness data attributes, of which one excluded', () => { | ||
document.body.innerHTML = ` | ||
<h2>Basic Example</h2> | ||
<section> | ||
<div id="first" class="example" data-onscreenness>Example Element with data-onscreenness attribute</div> | ||
<div id="second" class="example">Basic Example Element</div> | ||
<div id="third" class="example">Basic Example Element</div> | ||
<div id="fourth" class="example" data-onscreenness>Example Element with data-onscreenness attribute</div> | ||
<div id="fifth" class="example">Basic Example Element</div> | ||
<div id="sixth" class="example">Basic Example Element</div> | ||
<div id="seventh" class="example" data-onscreenness>Example Element with data-onscreenness attribute</div> | ||
<div id="eighth" class="example">Basic Example Element</div> | ||
</section> | ||
`; | ||
onScreenness.exclude('#fourth') | ||
let nodes = liveList(); | ||
expect(nodes.length).toBe(2); | ||
}); | ||
|
||
}); |