-
Notifications
You must be signed in to change notification settings - Fork 160
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 #591 from auth0/validate-for-unreplaced-keywords
Check for unreplaced keywords before import
- Loading branch information
Showing
2 changed files
with
110 additions
and
1 deletion.
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
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,69 @@ | ||
import { expect } from 'chai'; | ||
import { findUnreplacedKeywords } from '../../src/commands/import'; | ||
|
||
describe('#findUnreplacedKeywords function', () => { | ||
it('should not throw if no unreplaced keywords', () => { | ||
const fn = () => | ||
findUnreplacedKeywords({ | ||
actions: [ | ||
{ | ||
foo: 'foo', | ||
bar: 'bar', | ||
}, | ||
{ | ||
foo: ['foo1', 'foo2'], | ||
bar: 'bar', | ||
}, | ||
{ | ||
foo: 'foo', | ||
bar: 'bar', | ||
}, | ||
], | ||
tenant: { | ||
foo: 'foo', | ||
bar: { | ||
some: { | ||
nested: { property: 'bar baz' }, | ||
}, | ||
}, | ||
}, | ||
//@ts-ignore because we're detecting this | ||
databases: ' database value ', // | ||
}); | ||
|
||
expect(fn).to.not.throw(); | ||
}); | ||
it('should throw if unreplaced keywords detected', () => { | ||
const fn = () => | ||
findUnreplacedKeywords({ | ||
actions: [ | ||
{ | ||
foo: 'foo', | ||
bar: 'bar', | ||
}, | ||
{ | ||
foo: ['##KEYWORD1##', '##KEYWORD2##'], | ||
bar: 'bar', | ||
}, | ||
{ | ||
foo: 'foo', | ||
bar: 'bar', | ||
}, | ||
], | ||
tenant: { | ||
foo: 'foo', | ||
bar: { | ||
some: { | ||
nested: { property: 'bar ##KEYWORD3##' }, | ||
}, | ||
}, | ||
}, | ||
//@ts-ignore because we're detecting this | ||
databases: ' @@KEYWORD4@@ ', // | ||
}); | ||
|
||
expect(fn).to.throw( | ||
'Unreplaced keywords found: KEYWORD1, KEYWORD2, KEYWORD3, KEYWORD4. Either correct these values or add to AUTH0_KEYWORD_REPLACE_MAPPINGS configuration.' | ||
); | ||
}); | ||
}); |