Skip to content

Commit 58e366a

Browse files
committedNov 30, 2023
feat: add tests
1 parent e0e9235 commit 58e366a

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { VueQueryPlugin } from '@tanstack/vue-query';
2+
import { render, waitFor } from '@testing-library/vue';
3+
import { describe, expect, it, vi } from 'vitest';
4+
import * as customInstanceModule from '../../api/mutator/custom-instance';
5+
import Pet from './url-encode.vue';
6+
7+
describe('URL encode', () => {
8+
it('works', async () => {
9+
// this test is to ensure we have `/v${encodeURIComponent(String(unref(petId)))}/pets` instead of `/v${unref(petId)}/pets`
10+
11+
const spy = vi.spyOn(customInstanceModule, 'customInstance');
12+
13+
render(Pet, {
14+
props: {
15+
petId: '?me=yes&you',
16+
},
17+
global: {
18+
plugins: [VueQueryPlugin],
19+
},
20+
});
21+
22+
await waitFor(() => {
23+
expect(spy).toHaveBeenCalledWith(
24+
expect.objectContaining({
25+
url: '/v1/pets/%3Fme%3Dyes%26you', // NOT `/v1/pets/?me=yes&you`
26+
}),
27+
);
28+
});
29+
});
30+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script lang="ts" setup>
2+
import { useShowPetById } from '../../api/endpoints/petstoreFromFileSpecWithTransformer';
3+
4+
const props = defineProps<{ petId: string }>();
5+
useShowPetById(props.petId);
6+
</script>

0 commit comments

Comments
 (0)
Please sign in to comment.