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
48 lines (43 loc) · 1.61 KB
/
BuildEnvironment.spec.ts
File metadata and controls
48 lines (43 loc) · 1.61 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
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 = useAppConfig().buildInfo as BuildInfo
const component = await mountSuspended(BuildEnvironment, {
props: {
buildInfo,
},
})
const html = component.html()
// In dev mode, it shows env name, not version link
expect(html).toContain('<span class="tracking-wider">dev</span>')
expect(html).toContain(
'<a href="https://github.com/npmx-dev/npmx.dev/commit/704987bba88909f3782d792c224bde989569acb9"',
)
expect(html).not.toContain('href="https://github.com/npmx-dev/npmx.dev/tag/v0.0.0"')
})
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,
},
})
const html = component.html()
// In release mode, it shows tag version link, not env name
expect(html).not.toContain('<span class="tracking-wider">dev</span>')
expect(html).not.toContain(
'<a href="https://github.com/npmx-dev/npmx.dev/commit/704987bba88909f3782d792c224bde989569acb9"',
)
expect(html).toContain('href="https://github.com/npmx-dev/npmx.dev/tag/v1.2.3"')
})
})