You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

56 lines
1.6 KiB

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 = '<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);
});
});
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;
});
});
});