summaryrefslogtreecommitdiff
path: root/spec/javascripts/lib/utils/image_utility_spec.js
blob: a7eff419fba6c6222b8f9697b165aed7df8d72d5 (plain)
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
import { isImageLoaded } from '~/lib/utils/image_utility';

describe('imageUtility', () => {
  describe('isImageLoaded', () => {
    it('should return false when image.complete is false', () => {
      const element = {
        complete: false,
        naturalHeight: 100,
      };

      expect(isImageLoaded(element)).toEqual(false);
    });

    it('should return false when naturalHeight = 0', () => {
      const element = {
        complete: true,
        naturalHeight: 0,
      };

      expect(isImageLoaded(element)).toEqual(false);
    });

    it('should return true when image.complete and naturalHeight != 0', () => {
      const element = {
        complete: true,
        naturalHeight: 100,
      };

      expect(isImageLoaded(element)).toEqual(true);
    });
  });
});