mcfly/packages/core/test/build.test.js
Ayo Ayco 73617647db
feat: move cli to core (#55)
* refactor: move cli to core

* feat: move cli to core

- use route-middleware in serve
- eliminate need for `routes` dir in app

* feat: use route-middleware in build

* chore: update test gh action
2025-01-08 21:21:31 +01:00

44 lines
904 B
JavaScript

import consola from 'consola'
import { vi, expect, test } from 'vitest'
import { exportedForTest } from '../cli/commands/build.mjs'
const testFn = exportedForTest.build
const mocks = vi.hoisted(() => {
return {
build: vi.fn(),
}
})
vi.mock('nitropack', () => {
return {
build: mocks.build,
}
})
test('start build with message', () => {
const message = 'Building project...'
const spy = vi.spyOn(consola, 'start')
testFn()
expect(spy).toHaveBeenCalledWith(message)
})
// test('execute nitropack build', () => {
// mocks.build.mockImplementation(() => {})
// testFn({ dir: '.' })
// expect(mocks.build).toHaveBeenCalled()
// })
// test('catch error', () => {
// const spy = vi.spyOn(consola, 'error')
// mocks.build.mockImplementationOnce(() => {
// throw new Error('hey')
// })
// testFn()
// expect(spy).toHaveBeenCalledWith(new Error('hey'))
// })