summaryrefslogtreecommitdiff
path: root/spec/javascripts/lib/utils/image_utility_spec.js
blob: 75addfcc833443be45650159a23368c5267e0e76 (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 * as imageUtility 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(imageUtility.isImageLoaded(element)).toEqual(false);
    });

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

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

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

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