Skip to content

Commit

Permalink
test(parser): ensure identifier can be escaped
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainLanz committed Jan 19, 2024
1 parent 821ef92 commit b5b63fa
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ test.group('Env Parser', () => {
})
})

test('allows to escape the identifier', async ({ assert, cleanup, expectTypeOf }) => {
cleanup(() => {
EnvParser.removeIdentifier('file')
})

EnvParser.identifier('file', (_value: string) => {
return '3000'
})

const envString = ['ENV_USER=file\\:///root/app/user.js'].join('\n')
const parser = new EnvParser(envString)
const parsed = await parser.parse()

expectTypeOf(parsed).toEqualTypeOf<DotenvParseOutput>()
assert.deepEqual(parsed, {
ENV_USER: 'file:///root/app/user.js',
})
})

test('throw when identifier is already defined', async ({ assert, cleanup }) => {
cleanup(() => {
EnvParser.removeIdentifier('file')
Expand Down

0 comments on commit b5b63fa

Please sign in to comment.