mcfly/packages/core/test/build.test.ts
Ayo 970970fd32 feat: use fastify as server
- [x] implement server framework plugin config
- [x] new @mcflyjs/fastify package
- [x] update readme re: pivot & target state
- [x] new basic template

Reviewed-on: https://git.ayo.run/ayo/mcfly/pulls/2
Co-authored-by: Ayo <ayo@ayco.io>
Co-committed-by: Ayo <ayo@ayco.io>
2026-06-04 11:03:45 +00:00

47 lines
970 B
TypeScript

import type { ParsedArgs } from 'citty'
import consola from 'consola'
import { expect, it, vi } from 'vitest'
import { exportedForTest } from '../src/commands/build'
const build = exportedForTest.build
const mocks = vi.hoisted(() => {
return {
build: vi.fn(),
}
})
vi.mock('nitropack', () => {
return {
build: mocks.build,
}
})
it('start build with message', () => {
const message = 'Building project...'
const spy = vi.spyOn(consola, 'start')
build({ dir: 'fakeDir', _: [] } as ParsedArgs)
expect(spy).toHaveBeenCalledWith(message)
})
// TODO
it.skip('execute nitropack build', () => {
mocks.build.mockImplementation(() => {})
build({ dir: '.', _: [] })
expect(mocks.build).toHaveBeenCalled()
})
// TODO
it.skip('catch error', () => {
const spy = vi.spyOn(consola, 'error')
mocks.build.mockImplementationOnce(() => {
throw new Error('hey')
})
build({ _: [] })
expect(spy).toHaveBeenCalledWith(new Error('hey'))
})