gitlab-org--gitlab-foss/spec/javascripts/lib/utils/image_utility_spec.js

33 lines
788 B
JavaScript
Raw Normal View History

import { isImageLoaded } from '~/lib/utils/image_utility';
2017-10-07 00:25:17 -04:00
describe('imageUtility', () => {
describe('isImageLoaded', () => {
it('should return false when image.complete is false', () => {
const element = {
complete: false,
naturalHeight: 100,
};
expect(isImageLoaded(element)).toEqual(false);
2017-10-07 00:25:17 -04:00
});
it('should return false when naturalHeight = 0', () => {
const element = {
complete: true,
naturalHeight: 0,
};
expect(isImageLoaded(element)).toEqual(false);
2017-10-07 00:25:17 -04:00
});
it('should return true when image.complete and naturalHeight != 0', () => {
const element = {
complete: true,
naturalHeight: 100,
};
expect(isImageLoaded(element)).toEqual(true);
2017-10-07 00:25:17 -04:00
});
});
});