-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
store.test.ts
67 lines (65 loc) · 1.88 KB
/
store.test.ts
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
57
58
59
60
61
62
63
64
65
66
67
import createStore from '../src/store'
import { createTemplatePM } from '../src/store/pm'
import {
clearLockFile,
readLockFile,
storeDir,
} from './helpers'
describe('pm', () => {
afterEach(() => {
clearLockFile()
})
it.todo('import github:neo-hack/actions-template should from store')
it('request should work', async () => {
const pm = await createTemplatePM({ storeDir })
const response = await pm.request({ alias: '@aiou/ts-lib-template' })
expect(response).toBeDefined()
})
it('request with version should work', async () => {
const pm = await createTemplatePM({ storeDir })
const response = await pm.request({ alias: '@aiou/bin-template', pref: '2.1.1' })
expect(response.body.manifest?.version).toBe('2.1.1')
})
})
describe('store', () => {
afterEach(() => {
clearLockFile()
})
// FIXME: latest option not working, will always install latest
it('add template', async () => {
const store = await createStore({ storeDir })
await store.addTemplate({
alias: '@aiou/bin-template',
latest: false,
name: 'bin',
pref: 'bin-template#bundle',
})
expect(readLockFile()).toMatchSnapshot()
})
it('add preset', async () => {
const store = await createStore({ storeDir })
await store.addPreset({
alias: '@aiou/preset-aiou',
latest: false,
name: 'aiou',
pref: '@aiou/preset-aiou',
})
expect(readLockFile()).toMatchSnapshot()
})
it('add(type=preset)', async () => {
const store = await createStore({ storeDir })
await store.add({
type: 'preset',
pref: '@aiou/preset-aiou',
})
expect(readLockFile()).toMatchSnapshot()
})
it('add(type=template)', async () => {
const store = await createStore({ storeDir })
await store.add({
type: 'template',
pref: '@aiou/bin-template@3.0.1',
})
expect(readLockFile()).toMatchSnapshot()
})
})