aboutsummaryrefslogtreecommitdiff
path: root/test/content/components/common/hint.test.ts
blob: 42d571f396adfee37c141c2cf7456ef486a62237 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
  });
});