1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import { expect } from "chai";
import * as navigates from '../../src/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;
});
});
});
|