Skip to content

Commit f435ff5

Browse files
committed
fixup: silliness
1 parent 1be6f67 commit f435ff5

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

src/__tests__/vite-plugin.test.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, deepClone, describe, expect, test, vi } from 'vitest'
1+
import { beforeEach, describe, expect, test, vi } from 'vitest'
22

33
import { svelteTesting } from '../vite.js'
44
import { IS_JEST } from './utils.js'
@@ -15,41 +15,41 @@ describe.skipIf(IS_JEST)('vite plugin', () => {
1515
noExternal: false,
1616
})
1717

18-
const config = {}
19-
subject.config(config)
18+
const result = {}
19+
subject.config(result)
2020

21-
expect(config).toEqual({})
21+
expect(result).toEqual({})
2222
})
2323

2424
test('does not modify config if not Vitest', () => {
2525
vi.stubEnv('VITEST', '')
2626

2727
const subject = svelteTesting()
28-
const config = {}
2928

30-
subject.config(config)
29+
const result = {}
30+
subject.config(result)
3131

32-
expect(config).toEqual({})
32+
expect(result).toEqual({})
3333
})
3434

3535
test.each([
3636
{
37-
config: { resolve: { conditions: ['node'] } },
37+
config: () => ({ resolve: { conditions: ['node'] } }),
3838
expectedConditions: ['browser', 'node'],
3939
},
4040
{
41-
config: { resolve: { conditions: ['svelte', 'node'] } },
41+
config: () => ({ resolve: { conditions: ['svelte', 'node'] } }),
4242
expectedConditions: ['svelte', 'browser', 'node'],
4343
},
4444
])(
4545
'adds browser condition if necessary',
4646
({ config, expectedConditions }) => {
4747
const subject = svelteTesting()
48-
const viteConfig = deepClone(config)
4948

50-
subject.config(viteConfig)
49+
const result = config()
50+
subject.config(result)
5151

52-
expect(viteConfig).toMatchObject({
52+
expect(result).toMatchObject({
5353
resolve: {
5454
conditions: expectedConditions,
5555
},
@@ -59,26 +59,26 @@ describe.skipIf(IS_JEST)('vite plugin', () => {
5959

6060
test.each([
6161
{
62-
config: {},
62+
config: () => ({}),
6363
expectedConditions: [],
6464
},
6565
{
66-
config: { resolve: { conditions: [] } },
66+
config: () => ({ resolve: { conditions: [] } }),
6767
expectedConditions: [],
6868
},
6969
{
70-
config: { resolve: { conditions: ['svelte'] } },
70+
config: () => ({ resolve: { conditions: ['svelte'] } }),
7171
expectedConditions: ['svelte'],
7272
},
7373
])(
7474
'skips browser condition if possible',
7575
({ config, expectedConditions }) => {
7676
const subject = svelteTesting()
77-
const viteConfig = deepClone(config)
7877

79-
subject.config(viteConfig)
78+
const result = config()
79+
subject.config(result)
8080

81-
expect(viteConfig).toMatchObject({
81+
expect(result).toMatchObject({
8282
resolve: {
8383
conditions: expectedConditions,
8484
},
@@ -88,27 +88,27 @@ describe.skipIf(IS_JEST)('vite plugin', () => {
8888

8989
test.each([
9090
{
91-
config: {},
91+
config: () => ({}),
9292
expectedSetupFiles: [expect.stringMatching(/src\/vitest.js$/u)],
9393
},
9494
{
95-
config: { test: { setupFiles: [] } },
95+
config: () => ({ test: { setupFiles: [] } }),
9696
expectedSetupFiles: [expect.stringMatching(/src\/vitest.js$/u)],
9797
},
9898
{
99-
config: { test: { setupFiles: 'other-file.js' } },
99+
config: () => ({ test: { setupFiles: 'other-file.js' } }),
100100
expectedSetupFiles: [
101101
'other-file.js',
102102
expect.stringMatching(/src\/vitest.js$/u),
103103
],
104104
},
105105
])('adds cleanup', ({ config, expectedSetupFiles }) => {
106106
const subject = svelteTesting()
107-
const viteConfig = deepClone(config)
108107

109-
subject.config(viteConfig)
108+
const result = config()
109+
subject.config(result)
110110

111-
expect(viteConfig).toMatchObject({
111+
expect(result).toMatchObject({
112112
test: {
113113
setupFiles: expectedSetupFiles,
114114
},
@@ -117,28 +117,28 @@ describe.skipIf(IS_JEST)('vite plugin', () => {
117117

118118
test.each([
119119
{
120-
config: { ssr: { noExternal: [] } },
120+
config: () => ({ ssr: { noExternal: [] } }),
121121
expectedNoExternal: ['@testing-library/svelte'],
122122
},
123123
{
124-
config: {},
124+
config: () => ({}),
125125
expectedNoExternal: ['@testing-library/svelte'],
126126
},
127127
{
128-
config: { ssr: { noExternal: 'other-file.js' } },
128+
config: () => ({ ssr: { noExternal: 'other-file.js' } }),
129129
expectedNoExternal: ['other-file.js', '@testing-library/svelte'],
130130
},
131131
{
132-
config: { ssr: { noExternal: /other/u } },
132+
config: () => ({ ssr: { noExternal: /other/u } }),
133133
expectedNoExternal: [/other/u, '@testing-library/svelte'],
134134
},
135135
])('adds noExternal rule', ({ config, expectedNoExternal }) => {
136136
const subject = svelteTesting()
137-
const viteConfig = deepClone(config)
138137

139-
subject.config(viteConfig)
138+
const result = config()
139+
subject.config(result)
140140

141-
expect(viteConfig).toMatchObject({
141+
expect(result).toMatchObject({
142142
ssr: {
143143
noExternal: expectedNoExternal,
144144
},
@@ -147,24 +147,24 @@ describe.skipIf(IS_JEST)('vite plugin', () => {
147147

148148
test.each([
149149
{
150-
config: { ssr: { noExternal: true } },
150+
config: () => ({ ssr: { noExternal: true } }),
151151
expectedNoExternal: true,
152152
},
153153
{
154-
config: { ssr: { noExternal: '@testing-library/svelte' } },
154+
config: () => ({ ssr: { noExternal: '@testing-library/svelte' } }),
155155
expectedNoExternal: '@testing-library/svelte',
156156
},
157157
{
158-
config: { ssr: { noExternal: /svelte/u } },
158+
config: () => ({ ssr: { noExternal: /svelte/u } }),
159159
expectedNoExternal: /svelte/u,
160160
},
161161
])('skips noExternal if able', ({ config, expectedNoExternal }) => {
162162
const subject = svelteTesting()
163-
const viteConfig = deepClone(config)
164163

165-
subject.config(viteConfig)
164+
const result = config()
165+
subject.config(result)
166166

167-
expect(viteConfig).toMatchObject({
167+
expect(result).toMatchObject({
168168
ssr: {
169169
noExternal: expectedNoExternal,
170170
},
@@ -173,11 +173,11 @@ describe.skipIf(IS_JEST)('vite plugin', () => {
173173

174174
test('bails on noExternal if input is unexpected', () => {
175175
const subject = svelteTesting()
176-
const viteConfig = deepClone({ ssr: { noExternal: false } })
177176

178-
subject.config(viteConfig)
177+
const result = { ssr: { noExternal: false } }
178+
subject.config(result)
179179

180-
expect(viteConfig).toMatchObject({
180+
expect(result).toMatchObject({
181181
ssr: {
182182
noExternal: false,
183183
},

0 commit comments

Comments
 (0)