username@email.com
2025-04-27 15eb82df2d6ec539e9d4245bfe08d531e8eb6379
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
describe('filter (option)', () => {
  it('should be null be default', () => {
    const image = window.createImage();
    const viewer = new Viewer(image);
 
    expect(viewer.options.filter).to.be.null;
  });
 
  it('should match the filtered image', (done) => {
    const imageList = window.createImageList();
    const viewer = new Viewer(imageList, {
      inline: true,
 
      filter(image) {
        expect(this).to.be.an.instanceof(Viewer);
 
        return /1\.jpg$/.test(image.src);
      },
 
      ready() {
        expect(viewer.list.childElementCount).to.equal(1);
        expect(viewer.list.querySelector('img').src).to.match(/1\.jpg$/);
        done();
      },
    });
  });
 
  it('should not be ready when ignore all images', () => {
    const imageList = window.createImageList();
 
    new Viewer(imageList, {
      inline: true,
 
      filter() {
        return false;
      },
 
      ready() {
        expect.fail(1, 0);
      },
    });
  });
});