username@email.com
2021-06-03 904fb460b9359fe92e00ce25804d96c8a52bb513
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
58
59
60
61
62
63
64
describe('title (option)', () => {
  it('should show title by default', (done) => {
    const image = window.createImage();
    const viewer = new Viewer(image, {
      inline: true,
 
      ready() {
        expect(window.getComputedStyle(viewer.title).display).to.not.equal('none');
        done();
      },
    });
 
    expect(viewer.options.title).to.be.true;
  });
 
  it('should not show title', (done) => {
    const image = window.createImage();
    const viewer = new Viewer(image, {
      inline: true,
      title: false,
 
      ready() {
        expect(window.getComputedStyle(viewer.title).display).to.equal('none');
        done();
      },
    });
 
    expect(viewer.options.title).to.be.false;
  });
 
  it('should support function', (done) => {
    const image = window.createImage();
    const viewer = new Viewer(image, {
      inline: true,
 
      title(img) {
        return img.alt;
      },
 
      ready() {
        expect(viewer.title.innerHTML).to.equal(image.alt);
        done();
      },
    });
 
    expect(viewer.options.title).to.be.a('function');
  });
 
  it('should support array', (done) => {
    const image = window.createImage();
    const viewer = new Viewer(image, {
      inline: true,
      title: [3, (img) => img.alt],
 
      ready() {
        expect(viewer.title.className).to.include('viewer-hide-sm-down');
        expect(viewer.title.innerHTML).to.equal(image.alt);
        done();
      },
    });
 
    expect(viewer.options.title).to.be.an('array');
  });
});