-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: completed SSMProvider implementation
- Loading branch information
1 parent
743f7e0
commit 7f24e91
Showing
2 changed files
with
70 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
60 changes: 60 additions & 0 deletions
60
packages/parameters/tests/unit/getParametersByName.test.ts
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,60 @@ | ||
/** | ||
* Test getParametersByName function | ||
* | ||
* @group unit/parameters/SSMProvider/getParametersByName/function | ||
*/ | ||
import { DEFAULT_PROVIDERS } from '../../src/BaseProvider'; | ||
import { SSMProvider, getParametersByName } from '../../src/SSMProvider'; | ||
|
||
describe('Function: getParametersByName', () => { | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('when called and a default provider doesn\'t exist, it instantiates one and returns the value', async () => { | ||
|
||
// Prepare | ||
const parameters = { | ||
'/foo/bar': { | ||
maxAge: 1000, | ||
}, | ||
'/foo/baz': { | ||
maxAge: 2000, | ||
} | ||
}; | ||
const getParametersByNameSpy = jest.spyOn(SSMProvider.prototype, 'getParametersByName').mockImplementation(); | ||
|
||
// Act | ||
await getParametersByName(parameters); | ||
|
||
// Assess | ||
expect(getParametersByNameSpy).toHaveBeenCalledWith(parameters, undefined); | ||
|
||
}); | ||
|
||
test('when called and a default provider exists, it uses it and returns the value', async () => { | ||
|
||
// Prepare | ||
const provider = new SSMProvider(); | ||
DEFAULT_PROVIDERS.ssm = provider; | ||
const parameters = { | ||
'/foo/bar': { | ||
maxAge: 1000, | ||
}, | ||
'/foo/baz': { | ||
maxAge: 2000, | ||
} | ||
}; | ||
const getParametersByNameSpy = jest.spyOn(provider, 'getParametersByName').mockImplementation(); | ||
|
||
// Act | ||
await getParametersByName(parameters); | ||
|
||
// Assess | ||
expect(getParametersByNameSpy).toHaveBeenCalledWith(parameters, undefined); | ||
expect(DEFAULT_PROVIDERS.ssm).toBe(provider); | ||
|
||
}); | ||
|
||
}); |