Skip to content

Commit

Permalink
eevert "remove two serve tests"
Browse files Browse the repository at this point in the history
This reverts commit afe80d0.
  • Loading branch information
redwoodjsbot committed Nov 8, 2021
1 parent afe80d0 commit 7f768ac
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion packages/cli/src/commands/__tests__/serve.test.js
Expand Up @@ -40,7 +40,11 @@ jest.mock('@redwoodjs/api-server', () => {

import yargs from 'yargs'

import { bothServerHandler } from '@redwoodjs/api-server'
import {
apiServerHandler,
bothServerHandler,
webServerHandler,
} from '@redwoodjs/api-server'

import { builder } from '../serve'

Expand All @@ -49,6 +53,48 @@ describe('yarn rw serve', () => {
jest.clearAllMocks()
})

it('Should proxy serve api with params to api-server handler', async () => {
const parser = yargs.command('serve [side]', false, builder)

parser.parse('serve api --port 5555 --apiRootPath funkyFunctions')

expect(apiServerHandler).toHaveBeenCalledWith(
expect.objectContaining({
port: 5555,
apiRootPath: expect.stringMatching(/^\/?funkyFunctions\/?$/),
})
)
})

it('Should proxy serve api with params to api-server handler (alias and slashes in path)', async () => {
const parser = yargs.command('serve [side]', false, builder)

parser.parse('serve api --port 5555 --rootPath funkyFunctions/nested/')

expect(apiServerHandler).toHaveBeenCalledWith(
expect.objectContaining({
port: 5555,
rootPath: expect.stringMatching(/^\/?funkyFunctions\/nested\/$/),
})
)
})

it('Should proxy serve web with params to web server handler', async () => {
const parser = yargs.command('serve [side]', false, builder)

parser.parse(
'serve web --port 9898 --socket abc --apiHost https://myapi.redwood/api'
)

expect(webServerHandler).toHaveBeenCalledWith(
expect.objectContaining({
port: 9898,
socket: 'abc',
apiHost: 'https://myapi.redwood/api',
})
)
})

it('Should proxy rw serve with params to appropriate handler', async () => {
const parser = yargs.command('serve [side]', false, builder)

Expand Down

0 comments on commit 7f768ac

Please sign in to comment.