Ensure images don't get stuck on opacity 0
This commit is contained in:
@@ -20,16 +20,38 @@ describe('Image', () => {
|
||||
expect(img.image).toBe(image);
|
||||
});
|
||||
|
||||
test('fadeIn should set the element opacity to 0', () => {
|
||||
test('fadeIn should set the element opacity to 1', () => {
|
||||
const img = new Image(image);
|
||||
img.fadeIn();
|
||||
expect(img.image.style.opacity).toBe('1');
|
||||
});
|
||||
|
||||
test('start should set the element opacity to 0', () => {
|
||||
const img = new Image(image);
|
||||
img.start();
|
||||
expect(img.image.style.opacity).toBe('0');
|
||||
});
|
||||
|
||||
test('showImage should set the element opacity to 1', () => {
|
||||
test('start should call fadeIn when image has already loaded', () => {
|
||||
const img = new Image(image);
|
||||
img.showImage();
|
||||
expect(img.image.style.opacity).toBe('1');
|
||||
img.fadeIn = jest.fn();
|
||||
Object.defineProperty(img.image, 'complete', {
|
||||
value: true,
|
||||
writable: false,
|
||||
});
|
||||
img.start();
|
||||
expect(img.fadeIn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('start should call attachLoadedEvent if image has not yet loaded', () => {
|
||||
const img = new Image(image);
|
||||
img.attachLoadedEvent = jest.fn();
|
||||
Object.defineProperty(img.image, 'complete', {
|
||||
value: false,
|
||||
writable: false,
|
||||
});
|
||||
img.start();
|
||||
expect(img.attachLoadedEvent).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user