Skip to content

Commit bbfa196

Browse files
committed
test: unit tests
1 parent ae9bac4 commit bbfa196

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/parameters/src/BaseProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ abstract class BaseProvider implements BaseProviderInterface {
132132

133133
}
134134

135-
const transformValue = (value: string | Uint8Array | undefined, transform: TransformOptions, throwOnTransformError: boolean, key: string = ''): string | Record<string, unknown> | undefined => {
135+
const transformValue = (value: string | Uint8Array | undefined, transform: TransformOptions, throwOnTransformError: boolean, key: string): string | Record<string, unknown> | undefined => {
136136
try {
137137
const normalizedTransform = transform.toLowerCase();
138138
if (

packages/parameters/tests/unit/BaseProvider.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ describe('Class: BaseProvider', () => {
217217
expect(value).toEqual('my-value');
218218

219219
});
220+
221+
test('when called with an auto transform, and the value is a valid JSON, it returns the parsed value', async () => {
222+
223+
// Prepare
224+
const mockData = JSON.stringify({ foo: 'bar' });
225+
const provider = new TestProvider();
226+
jest.spyOn(provider, '_get').mockImplementation(() => new Promise((resolve, _reject) => resolve(mockData)));
227+
228+
// Act
229+
const value = await provider.get('my-parameter.json', { transform: 'auto' });
230+
231+
// Assess
232+
expect(value).toStrictEqual({ foo: 'bar' });
233+
234+
});
220235

221236
});
222237

0 commit comments

Comments
 (0)