diff options
Diffstat (limited to 'test/content')
-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); + }); + }); +}); + + |