A fork of https://github.com/ueokande/vim-vixen
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.
56 lines
1.7 KiB
56 lines
1.7 KiB
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; |
|
}); |
|
}); |
|
}); |
|
|
|
|
|
|