From 4c9d0433a6ac851e72d50d6fb0451baa9d35fd35 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 15 Oct 2017 09:02:09 +0900 Subject: make top-content component and frame-content component --- test/content/components/common/follow.html | 12 ++++++ test/content/components/common/follow.test.js | 18 +++++++++ test/content/components/common/hint.html | 1 + test/content/components/common/hint.test.js | 58 +++++++++++++++++++++++++++ test/content/components/follow.html | 12 ------ test/content/components/follow.test.js | 18 --------- test/content/components/hint.html | 1 - test/content/components/hint.test.js | 58 --------------------------- 8 files changed, 89 insertions(+), 89 deletions(-) create mode 100644 test/content/components/common/follow.html create mode 100644 test/content/components/common/follow.test.js create mode 100644 test/content/components/common/hint.html create mode 100644 test/content/components/common/hint.test.js delete mode 100644 test/content/components/follow.html delete mode 100644 test/content/components/follow.test.js delete mode 100644 test/content/components/hint.html delete mode 100644 test/content/components/hint.test.js (limited to 'test') diff --git a/test/content/components/common/follow.html b/test/content/components/common/follow.html new file mode 100644 index 0000000..eb0decd --- /dev/null +++ b/test/content/components/common/follow.html @@ -0,0 +1,12 @@ + + + + link + invisible 1 + invisible 2 + not link +
link
+
link
+
link
+ + diff --git a/test/content/components/common/follow.test.js b/test/content/components/common/follow.test.js new file mode 100644 index 0000000..97bd1d2 --- /dev/null +++ b/test/content/components/common/follow.test.js @@ -0,0 +1,18 @@ +import { expect } from "chai"; +import FollowComponent from 'content/components/common/follow'; + +describe('FollowComponent', () => { + describe('#getTargetElements', () => { + beforeEach(() => { + document.body.innerHTML = __html__['test/content/components/common/follow.html']; + }); + + it('returns visible links', () => { + let targets = FollowComponent.getTargetElements(window); + expect(targets).to.have.lengthOf(3); + + let ids = Array.prototype.map.call(targets, (e) => e.id); + expect(ids).to.include.members(['visible_a', 'editable_div_1', 'editable_div_2']); + }); + }); +}); 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 @@ +link 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 + }); +}); + + diff --git a/test/content/components/follow.html b/test/content/components/follow.html deleted file mode 100644 index eb0decd..0000000 --- a/test/content/components/follow.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - link - invisible 1 - invisible 2 - not link -
link
-
link
-
link
- - diff --git a/test/content/components/follow.test.js b/test/content/components/follow.test.js deleted file mode 100644 index c8ae58b..0000000 --- a/test/content/components/follow.test.js +++ /dev/null @@ -1,18 +0,0 @@ -import { expect } from "chai"; -import FollowComponent from 'content/components/follow'; - -describe('FollowComponent', () => { - describe('#getTargetElements', () => { - beforeEach(() => { - document.body.innerHTML = __html__['test/content/components/follow.html']; - }); - - it('returns visible links', () => { - let targets = FollowComponent.getTargetElements(window); - expect(targets).to.have.lengthOf(3); - - let ids = Array.prototype.map.call(targets, (e) => e.id); - expect(ids).to.include.members(['visible_a', 'editable_div_1', 'editable_div_2']); - }); - }); -}); diff --git a/test/content/components/hint.html b/test/content/components/hint.html deleted file mode 100644 index b50c5fe..0000000 --- a/test/content/components/hint.html +++ /dev/null @@ -1 +0,0 @@ -link diff --git a/test/content/components/hint.test.js b/test/content/components/hint.test.js deleted file mode 100644 index f98b79b..0000000 --- a/test/content/components/hint.test.js +++ /dev/null @@ -1,58 +0,0 @@ -import { expect } from "chai"; -import Hint from 'content/components/hint'; - -describe('Hint class', () => { - beforeEach(() => { - document.body.innerHTML = __html__['test/content/components/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 - }); -}); - - -- cgit v1.2.3