diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-04-30 14:00:07 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-02 11:14:19 +0900 |
commit | c60d0e7392fc708e961614d6b756a045de74f458 (patch) | |
tree | 0b9a5fce1879e38a92d5dbb2915779aee0ad22d6 /test/content/components/common/hint.test.ts | |
parent | 257162e5b6b4993e1dff0d705ffa6f0d809033eb (diff) |
Rename .js/.jsx to .ts/.tsx
Diffstat (limited to 'test/content/components/common/hint.test.ts')
-rw-r--r-- | test/content/components/common/hint.test.ts | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/content/components/common/hint.test.ts b/test/content/components/common/hint.test.ts new file mode 100644 index 0000000..42d571f --- /dev/null +++ b/test/content/components/common/hint.test.ts @@ -0,0 +1,57 @@ +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 + }); +}); + + |