diff options
Diffstat (limited to 'test/content/components')
-rw-r--r-- | test/content/components/common/follow.html (renamed from test/content/components/follow.html) | 0 | ||||
-rw-r--r-- | test/content/components/common/follow.test.js (renamed from test/content/components/follow.test.js) | 9 | ||||
-rw-r--r-- | test/content/components/common/hint.html | 1 | ||||
-rw-r--r-- | test/content/components/common/hint.test.js | 58 |
4 files changed, 65 insertions, 3 deletions
diff --git a/test/content/components/follow.html b/test/content/components/common/follow.html index eb0decd..eb0decd 100644 --- a/test/content/components/follow.html +++ b/test/content/components/common/follow.html diff --git a/test/content/components/follow.test.js b/test/content/components/common/follow.test.js index 5c3e1d5..1fc935e 100644 --- a/test/content/components/follow.test.js +++ b/test/content/components/common/follow.test.js @@ -1,14 +1,17 @@ import { expect } from "chai"; -import FollowComponent from 'content/components/follow'; +import FollowComponent from 'content/components/common/follow'; describe('FollowComponent', () => { describe('#getTargetElements', () => { beforeEach(() => { - document.body.innerHTML = __html__['test/content/components/follow.html']; + document.body.innerHTML = __html__['test/content/components/common/follow.html']; }); it('returns visible links', () => { - let targets = FollowComponent.getTargetElements(window.document); + let targets = FollowComponent.getTargetElements( + window, + { width: window.innerWidth, height: window.innerHeight }, + { x: 0, y: 0 }); expect(targets).to.have.lengthOf(3); let ids = Array.prototype.map.call(targets, (e) => e.id); diff --git a/test/content/components/common/hint.html b/test/content/components/common/hint.html new file mode 100644 index 0000000..b50c5fe --- /dev/null +++ b/test/content/components/common/hint.html @@ -0,0 +1 @@ +<a id='test-link' href='javascript:window.vimvixenTest="hello"' >link</a> diff --git a/test/content/components/common/hint.test.js b/test/content/components/common/hint.test.js new file mode 100644 index 0000000..ced2fde --- /dev/null +++ b/test/content/components/common/hint.test.js @@ -0,0 +1,58 @@ +import { expect } from "chai"; +import Hint from 'content/components/common/hint'; + +describe('Hint class', () => { + beforeEach(() => { + document.body.innerHTML = __html__['test/content/components/common/hint.html']; + }); + + describe('#constructor', () => { + it('creates a hint element with tag name', () => { + let link = document.getElementById('test-link'); + let hint = new Hint(link, 'abc'); + expect(hint.element.textContent.trim()).to.be.equal('abc'); + }); + + it('throws an exception when non-element given', () => { + expect(() => new Hint(window, 'abc')).to.throw(TypeError); + }); + }); + + describe('#show', () => { + it('shows an element', () => { + let link = document.getElementById('test-link'); + let hint = new Hint(link, 'abc'); + hint.hide(); + hint.show(); + + expect(hint.element.style.display).to.not.equal('none'); + }); + }); + + describe('#hide', () => { + it('hides an element', () => { + let link = document.getElementById('test-link'); + let hint = new Hint(link, 'abc'); + hint.hide(); + + expect(hint.element.style.display).to.equal('none'); + }); + }); + + describe('#remove', () => { + it('removes an element', () => { + let link = document.getElementById('test-link'); + let hint = new Hint(link, 'abc'); + + expect(hint.element.parentElement).to.not.be.null; + hint.remove(); + expect(hint.element.parentElement).to.be.null; + }); + }); + + describe('#activate', () => { + // TODO test activations + }); +}); + + |