1
0
mirror of synced 2025-12-19 18:11:23 -05:00
Files
blitz/packages/cli/test/commands/start.test.ts
Justin Hall b3814fc7c0 Standardize prettier options across all Blitz code bases (#703)
Co-authored-by: Brandon Bayer <b@bayer.ws> (meta)
2020-06-19 09:33:57 +07:00

40 lines
944 B
TypeScript

const dev = jest.fn(() => {})
const prod = jest.fn(() => {})
jest.mock("@blitzjs/server", () => ({dev, prod, resolveBinAsync: jest.fn()}))
let onSpy: jest.Mock
const spawn = jest.fn(() => {
onSpy = jest.fn(function on(_: string, callback: (_: number) => {}) {
callback(0)
})
return {on: onSpy}
})
jest.doMock("cross-spawn", () => ({spawn}))
import {Start} from "../../src/commands/start"
import {resolve} from "path"
describe("Start command", () => {
beforeEach(() => {
jest.clearAllMocks()
})
const options = {
rootFolder: resolve(__dirname, "../../"),
port: 3000,
hostname: "localhost",
}
it("runs the dev script", async () => {
await Start.run([])
expect(dev).toBeCalledWith(options, Promise.resolve())
})
it("runs the prod script when passed the production flag", async () => {
await Start.run(["--production"])
expect(prod).toBeCalledWith(options, Promise.resolve())
})
})