forked from npmx-dev/npmx.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildEnvironment.spec.ts
More file actions
56 lines (51 loc) · 1.78 KB
/
BuildEnvironment.spec.ts
File metadata and controls
56 lines (51 loc) · 1.78 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
45
46
47
48
49
50
51
52
53
54
55
56
import type { BuildInfo } from '#shared/types'
import { describe, expect, it } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import BuildEnvironment from '~/components/BuildEnvironment.vue'
describe('BuildEnvironment', () => {
it('renders dev environment correctly', async () => {
const buildInfo: BuildInfo = {
env: 'dev',
version: '1.2.3',
time: 1234567890,
commit: 'abcdef',
shortCommit: 'abc',
branch: 'main',
}
const component = await mountSuspended(BuildEnvironment, {
props: {
buildInfo,
},
})
// In dev mode, it shows env name, not version link
const envSpan = component.find('span.tracking-wider')
expect(envSpan.exists()).toBe(true)
expect(envSpan.text()).toBe(buildInfo.env)
const commitLink = component.find(`a[href$="/commit/${buildInfo.commit}"]`)
expect(commitLink.exists()).toBe(true)
const tagLink = component.find(`a[href$="/tag/v${buildInfo.commit}"]`)
expect(tagLink.exists()).toBe(false)
})
it('renders release environment correctly', async () => {
const buildInfo: BuildInfo = {
env: 'release',
version: '1.2.3',
time: 1234567890,
commit: 'abcdef',
shortCommit: 'abc',
branch: 'release',
}
const component = await mountSuspended(BuildEnvironment, {
props: {
buildInfo,
},
})
// In release mode, it shows tag version link, not env name
const envSpan = component.find('span.tracking-wider')
expect(envSpan.exists()).toBe(false)
const commitLink = component.find(`a[href$="/commit/${buildInfo.commit}"]`)
expect(commitLink.exists()).toBe(false)
const tagLink = component.find(`a[href$="/tag/v${buildInfo.version}"]`)
expect(tagLink.exists()).toBe(true)
})
})