Skip to content

Commit 441b968

Browse files
committed
chore: mock pulumi automation API
1 parent 8573c5f commit 441b968

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

tests/adapter.test.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
11
import * as fs from 'fs'
22
import * as path from 'path'
3-
import prepAdapter from 'sveltekit-adapter-aws-base'
3+
4+
import {
5+
buildServer,
6+
buildOptions,
7+
buildRouter,
8+
} from 'sveltekit-adapter-aws-base'
49

510
import { getTempDir } from './utils'
611

7-
vi.mock('child_process')
812
vi.mock('sveltekit-adapter-aws-base')
13+
vi.mock('@pulumi/pulumi/automation/index.js', () => {
14+
const Stack = {
15+
setConfig: vi.fn(),
16+
setAllConfig: vi.fn(),
17+
getAllConfig: vi.fn(() => {return {}}),
18+
up: vi.fn(() => {return {
19+
outputs: {
20+
serverDomain: {
21+
value: 'mock'
22+
},
23+
optionsDomain: {
24+
value: 'mock'
25+
},
26+
allowedOrigins: {
27+
value: ['mock']
28+
}
29+
}
30+
}
31+
}),
32+
}
33+
const LocalWorkspace = {
34+
createOrSelectStack: vi.fn(() => Stack)
35+
}
36+
37+
return {
38+
LocalWorkspace
39+
}
40+
})
941

1042
describe('adapter.ts', () => {
1143
let adapter: typeof import('../adapter')
@@ -16,14 +48,19 @@ describe('adapter.ts', () => {
1648
})
1749

1850
it('Store adapter props', async () => {
19-
;(prepAdapter as any).mockImplementation(() => {
51+
;(buildServer as any).mockImplementation(() => {
2052
return {
2153
server_directory: 'mock',
2254
static_directory: 'mock',
2355
prerendered_directory: 'mock',
24-
routes: ['mock'],
2556
}
2657
})
58+
;(buildOptions as any).mockImplementation(() => {
59+
return 'mock'
60+
})
61+
;(buildRouter as any).mockImplementation(() => {
62+
return 'mock'
63+
})
2764

2865
const builder = {
2966
log: {

0 commit comments

Comments
 (0)