import { expect } from "chai"; import * as navigates from 'content/navigates'; describe('navigates module', () => { describe('#linkPrev', () => { it('clicks prev link by text content', (done) => { document.body.innerHTML = 'xprevx go to prev'; navigates.linkPrev(window); setTimeout(() => { expect(document.location.hash).to.equal('#prev'); done(); }, 0); }); it('clicks a[rel=prev] element preferentially', (done) => { document.body.innerHTML = 'prev '; 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 = 'xnextx go to next'; navigates.linkNext(window); setTimeout(() => { expect(document.location.hash).to.equal('#next'); done(); }, 0); }); it('clicks a[rel=next] element preferentially', (done) => { document.body.innerHTML = 'next '; navigates.linkNext(window); setTimeout(() => { expect(document.location.hash).to.equal('#next'); done(); }, 0); }); }); describe('#parent', () => { // NOTE: not able to test location it('removes hash', () => { window.location.hash = "#section-1"; navigates.parent(window); expect(document.location.hash).to.be.empty; }); }); });