diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-17 10:52:09 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-17 11:54:21 +0900 |
commit | ac8b40a2f3a50bb30f121dcc1a454074498e7bf7 (patch) | |
tree | 23cfcc61c02bf2e475a003d581027506bab34902 /test/content/navigates.test.js | |
parent | aeb0e0f96de7b2f9b5a143c8a900e2349bb0702a (diff) |
pagenate by prev/next links
Diffstat (limited to 'test/content/navigates.test.js')
-rw-r--r-- | test/content/navigates.test.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/content/navigates.test.js b/test/content/navigates.test.js new file mode 100644 index 0000000..21c2a23 --- /dev/null +++ b/test/content/navigates.test.js @@ -0,0 +1,50 @@ +import { expect } from "chai"; +import * as navigates from '../../src/content/navigates'; + +describe('navigates module', () => { + beforeEach(() => { + }); + + describe('#linkPrev', () => { + it('clicks prev link by text content', (done) => { + document.body.innerHTML = '<a href="#dummy">xprevx</a> <a href="#prev">go to prev</a>'; + navigates.linkPrev(window); + setTimeout(() => { + expect(document.location.hash).to.equal('#prev'); + done(); + }, 0); + }); + + it('clicks a[rel=prev] element preferentially', (done) => { + document.body.innerHTML = '<a href="#dummy">prev</a> <a rel="prev" href="#prev">rel</a>'; + navigates.linkPrev(window); + setTimeout(() => { + expect(document.location.hash).to.equal('#prev'); + done(); + }, 0); + }); + }); + + + describe('#linkNext', () => { + it('clicks next link by text content', (done) => { + document.body.innerHTML = '<a href="#dummy">xnextx</a> <a href="#next">go to next</a>'; + navigates.linkNext(window); + setTimeout(() => { + expect(document.location.hash).to.equal('#next'); + done(); + }, 0); + }); + + it('clicks a[rel=next] element preferentially', (done) => { + document.body.innerHTML = '<a href="#dummy">next</a> <a rel="next" href="#next">rel</a>'; + navigates.linkNext(window); + setTimeout(() => { + expect(document.location.hash).to.equal('#next'); + done(); + }, 0); + }); + }); +}); + + |