-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupgrade.test.ts
More file actions
44 lines (37 loc) · 1.33 KB
/
upgrade.test.ts
File metadata and controls
44 lines (37 loc) · 1.33 KB
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
import { describe, expect, it } from 'vitest'
import { checkUpgrade } from '../../src/providers/diagnostics/rules/upgrade'
import { createContext } from './context'
function createUpgradeContext(version: string) {
return createContext({
name: 'vite',
version,
distTags: {
latest: '2.7.0',
next: '3.0.0-alpha.5',
},
versionsMeta: {
'1.0.0': {},
'2.7.0': {},
'3.0.0-alpha.1': {},
'3.0.0-alpha.5': {},
},
})
}
describe('checkUpgrade', () => {
it('should create upgrade diagnostic payload', async () => {
const result = await checkUpgrade(createUpgradeContext('^1.0.0'))
expect(result).toBeDefined()
expect(result!.code).toMatchObject({ value: 'upgrade' })
expect(result!.message).toMatchInlineSnapshot('"New version available: ^2.7.0"')
})
it('should preserve protocol prefix in diagnostic message', async () => {
const result = await checkUpgrade(createUpgradeContext('npm:^1.0.0'))
expect(result).toBeDefined()
expect(result!.code).toMatchObject({ value: 'upgrade' })
expect(result!.message).toMatchInlineSnapshot('"New version available: npm:^2.7.0"')
})
it('should return undefined for unsupported protocol', async () => {
const result = await checkUpgrade(createUpgradeContext('workspace:^1.0.0'))
expect(result).toBeUndefined()
})
})