aboutsummaryrefslogtreecommitdiff
path: root/test/content/hint.test.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-08-21 22:19:01 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-08-21 22:19:01 +0900
commita052ec92b7c7f27447211222231f43f07c2990c8 (patch)
tree8cb109444a10f9acfe2d3a999b1adb7a88f24abe /test/content/hint.test.js
parentc50f463bc12da7e3a5de490b714b4ff1ea8d3e56 (diff)
add Hint tests
Diffstat (limited to 'test/content/hint.test.js')
-rw-r--r--test/content/hint.test.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/content/hint.test.js b/test/content/hint.test.js
new file mode 100644
index 0000000..9b2ab6e
--- /dev/null
+++ b/test/content/hint.test.js
@@ -0,0 +1,58 @@
+import { expect } from "chai";
+import Hint from '../../src/content/hint';
+
+describe('Hint class', () => {
+ beforeEach(() => {
+ document.body.innerHTML = __html__['test/content/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
+ });
+});
+
+