/
PixImage.test.js
56 lines (48 loc) · 1.36 KB
/
PixImage.test.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
import { shallowMount } from '@vue/test-utils'
import PixImage from '~/components/PixImage'
describe('Component: PixImage', () => {
let component
beforeEach(() => {
component = shallowMount(PixImage, {
stubs: { 'prismic-image': true },
props: { field: {} },
})
})
describe('Computed Property : Image', () => {
it('should return the same image object if there is an alt', async () => {
// Given
const imageWithAlt = {
alt: 'Alternative Message',
copyright: null,
dimension: {
height: 345,
width: 453,
},
url: 'https://url.fr',
}
// When
await component.setProps({ field: imageWithAlt })
// Then
expect(component.vm.image).toEqual(imageWithAlt)
})
it('should return the image object with empty alt and role when there is not alt', async () => {
// Given
const imageWithoutAlt = {
alt: null,
copyright: null,
dimension: {
height: 345,
width: 453,
},
url: 'https://url.fr',
}
const expectedImage = Object.assign({}, imageWithoutAlt)
expectedImage.alt = ''
expectedImage.role = 'presentation'
// When
await component.setProps({ field: imageWithoutAlt })
// Then
expect(component.vm.image).toEqual(expectedImage)
})
})
})