Skip to content

Commit

Permalink
Fix test snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoBakerHytch committed Aug 29, 2019
1 parent 2488330 commit 1cca8c5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/EnvError.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { EnvSchemaValue } from './types';

export enum EnvErrorType {
MISSING,
WRONG_TYPE,
MISSING = 'MISSING',
WRONG_TYPE = 'WRONG_TYPE',
}

export type EnvErrorReport = {
[key: string]: {
type: EnvErrorType;
schemaValue: EnvSchemaValue;
value?: string;
receivedValue?: string;
};
};

Expand All @@ -26,8 +26,8 @@ export class EnvError extends Error {

function formatReport(report: EnvErrorReport) {
const errors = Object.entries(report).map(entry => {
const [key, { type, schemaValue, value }] = entry;
return formatError(key, type, schemaValue, value);
const [key, { type, schemaValue, receivedValue }] = entry;
return formatError(key, type, schemaValue, receivedValue);
});
return `Invalid or missing environment variables\n - ${errors.join('\n - ')}\n`;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function validateSchema(schema: EnvSchema, env: Env): EnvErrorReport | null {
report[key] = {
type: EnvErrorType.WRONG_TYPE,
schemaValue,
value,
receivedValue: value,
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/__snapshots__/validate.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`validate reporting should report badly typed variables 1`] = `
"EnvError: Invalid or missing environment variables
"Invalid or missing environment variables
- Expected value for key 'BOOLEAN' of type Boolean; got '123'
- Expected value for key 'NUMBER' of type Number; got 'abc'
- Expected value for key 'REGEXP' to match /abc/; got 'true'
"
`;

exports[`validate reporting should report missing variables 1`] = `
"EnvError: Invalid or missing environment variables
"Invalid or missing environment variables
- Expected value for key 'MISSING'; none found
"
`;

0 comments on commit 1cca8c5

Please sign in to comment.