Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #998 from chardos/prefix-unit-integration-tests
chore(tests): generateHapiPath unit tests, prefix integration test
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import generateHapiPath from '../generateHapiPath.js' | ||
|
||
const serverless = { | ||
service: { | ||
provider: { | ||
stage: 'dev', | ||
}, | ||
}, | ||
} | ||
|
||
describe('generateHapiPath', () => { | ||
test('should generate url starting with a slash', () => { | ||
const options = {} | ||
const result = generateHapiPath('users', options, serverless) | ||
expect(result[0]).toEqual('/') | ||
}) | ||
|
||
test('should generate url with the stage prepended', () => { | ||
const options = {} | ||
const result = generateHapiPath('users', options, serverless) | ||
expect(result).toEqual('/dev/users') | ||
}) | ||
|
||
describe('when a prefix option is set', () => { | ||
test('the url should add the prefix', () => { | ||
const options = { prefix: 'some-prefix' } | ||
const result = generateHapiPath('users', options, serverless) | ||
expect(result).toEqual('/some-prefix/dev/users') | ||
}) | ||
}) | ||
|
||
describe('when the noPrependStageInUrl option is set', () => { | ||
test('the url should omit the stage', () => { | ||
const options = { noPrependStageInUrl: true } | ||
const result = generateHapiPath('users', options, serverless) | ||
expect(result).toEqual('/users') | ||
}) | ||
}) | ||
|
||
test('the stage from options should override stage from serverless config', () => { | ||
const options = { stage: 'prod' } | ||
const result = generateHapiPath('users', options, serverless) | ||
expect(result).toEqual('/prod/users') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters