make top-content component and frame-content component
This commit is contained in:
parent
042aa94936
commit
4c9d0433a6
13 changed files with 102 additions and 76 deletions
12
test/content/components/common/follow.html
Normal file
12
test/content/components/common/follow.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<a id='visible_a' href='#' >link</a>
|
||||
<a href='#' style='display:none'>invisible 1</a>
|
||||
<a href='#' style='visibility:hidden'>invisible 2</a>
|
||||
<i>not link<i>
|
||||
<div id='editable_div_1' contenteditable>link</div>
|
||||
<div id='editable_div_2' contenteditable='true'>link</div>
|
||||
<div id='x' contenteditable='false'>link</div>
|
||||
</body>
|
||||
</html>
|
18
test/content/components/common/follow.test.js
Normal file
18
test/content/components/common/follow.test.js
Normal file
|
@ -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']);
|
||||
});
|
||||
});
|
||||
});
|
1
test/content/components/common/hint.html
Normal file
1
test/content/components/common/hint.html
Normal file
|
@ -0,0 +1 @@
|
|||
<a id='test-link' href='javascript:window.vimvixenTest="hello"' >link</a>
|
58
test/content/components/common/hint.test.js
Normal file
58
test/content/components/common/hint.test.js
Normal file
|
@ -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
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in a new issue