Skip to content

Commit c33520c

Browse files
committed
test(ix-component): use beta and vue 3 syntax
This commit updates `imgix-component.spec.ts` to use `@testing-library/vue`'s new beta syntax. This means renaming `propsData` to `props`. The commit also updates the Vue app syntax to use the new Global API from vue 3. For more context on this change see here: testing-library/vue-testing-library#137
1 parent 7a2b14e commit c33520c

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

tests/unit/imgix-component.spec.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
import { createApp } from 'vue';
12
import VueImgix, { IxImg } from '@/plugins/vue-imgix';
23
import '@testing-library/jest-dom';
34
import { render } from '@testing-library/vue';
4-
import Vue from 'vue';
5+
import _App from '../../src/App.vue';
56
import {
67
expectElementToHaveFixedSrcAndSrcSet,
78
expectElementToHaveFluidSrcAndSrcSet,
89
} from '../helpers/url-assert';
10+
11+
const App = createApp(_App);
12+
913
describe('imgix component', () => {
1014
beforeAll(() => {
11-
Vue.use(VueImgix, {
15+
App.use(VueImgix, {
1216
domain: 'assets.imgix.net',
1317
});
1418
});
1519
it('an img should be rendered', () => {
1620
const wrapper = render(IxImg, {
17-
propsData: {
21+
props: {
1822
src: 'examples/pione.jpg',
1923
'data-testid': 'img-rendering',
2024
},
@@ -24,7 +28,7 @@ describe('imgix component', () => {
2428
});
2529
it(`the rendered img's src should be set`, () => {
2630
const wrapper = render(IxImg, {
27-
propsData: {
31+
props: {
2832
src: 'examples/pione.jpg',
2933
'data-testid': 'img-rendering',
3034
},
@@ -37,7 +41,7 @@ describe('imgix component', () => {
3741
});
3842
it(`the rendered img's srcset should be set correctly`, () => {
3943
const wrapper = render(IxImg, {
40-
propsData: {
44+
props: {
4145
src: 'examples/pione.jpg',
4246
'data-testid': 'img-rendering',
4347
},
@@ -60,7 +64,7 @@ describe('imgix component', () => {
6064

6165
it('imgixParams should be set on the rendered src and srcset', () => {
6266
const wrapper = render(IxImg, {
63-
propsData: {
67+
props: {
6468
'data-testid': 'img-rendering',
6569
src: 'examples/pione.jpg',
6670
imgixParams: { crop: 'faces' },
@@ -80,7 +84,7 @@ describe('imgix component', () => {
8084
describe('in fluid mode (no fixed props set)', () => {
8185
it('ix-img should render a fluid image if width is passed as attribute', () => {
8286
const wrapper = render(IxImg, {
83-
propsData: {
87+
props: {
8488
'data-testid': 'img-rendering',
8589
src: 'examples/pione.jpg',
8690
width: 100,
@@ -95,7 +99,7 @@ describe('imgix component', () => {
9599
describe('in fixed mode (fixed prop set, or width/height passed to imgixParams)', () => {
96100
it('the src and srcset should be in fixed size mode when a width is passed to imgixParams', () => {
97101
const wrapper = render(IxImg, {
98-
propsData: {
102+
props: {
99103
'data-testid': 'img-rendering',
100104
src: 'examples/pione.jpg',
101105
imgixParams: {
@@ -109,7 +113,7 @@ describe('imgix component', () => {
109113
});
110114
it('the src and srcset should be in fixed size mode when a fixed prop is passed to the element', () => {
111115
const wrapper = render(IxImg, {
112-
propsData: {
116+
props: {
113117
'data-testid': 'img-rendering',
114118
src: 'examples/pione.jpg',
115119
width: 100,
@@ -127,7 +131,7 @@ describe('imgix component', () => {
127131

128132
it('a width attribute should be passed through to the underlying component', () => {
129133
const wrapper = render(IxImg, {
130-
propsData: {
134+
props: {
131135
'data-testid': 'img-rendering',
132136
src: 'examples/pione.jpg',
133137
width: 100,
@@ -141,7 +145,7 @@ describe('imgix component', () => {
141145
});
142146
it('a height attribute should be passed through to the underlying component', () => {
143147
const wrapper = render(IxImg, {
144-
propsData: {
148+
props: {
145149
'data-testid': 'img-rendering',
146150
src: 'examples/pione.jpg',
147151
height: 100,
@@ -160,7 +164,7 @@ describe('imgix component', () => {
160164
ATTRIBUTES.forEach((attribute) => {
161165
it(`${attribute} can be configured to use data-${attribute}`, () => {
162166
const wrapper = render(IxImg, {
163-
propsData: {
167+
props: {
164168
'data-testid': 'img-rendering',
165169
src: 'examples/pione.jpg',
166170
attributeConfig: {
@@ -197,14 +201,14 @@ describe('imgix component', () => {
197201
};
198202
const ImgixClient = require('imgix-core-js');
199203
ImgixClient.mockImplementation(() => mockImgixClient);
200-
_Vue.use(_VueImgix, {
204+
_App.use(_VueImgix, {
201205
domain: 'assets.imgix.net',
202206
});
203207
/* eslint-enable @typescript-eslint/no-var-requires */
204208
});
205209
it('should not pass disableVariableQuality: true to imgix-core-js by default', () => {
206210
render(_IxImg, {
207-
propsData: {
211+
props: {
208212
src: 'examples/pione.jpg',
209213
height: 100,
210214
fixed: true,
@@ -221,7 +225,7 @@ describe('imgix component', () => {
221225
});
222226
it('should pass disableVariableQuality: true to imgix-core-js when disableVariableQuality prop set', () => {
223227
render(_IxImg, {
224-
propsData: {
228+
props: {
225229
src: 'examples/pione.jpg',
226230
height: 100,
227231
disableVariableQuality: true,

0 commit comments

Comments
 (0)