refactor(config): Reify snapshot tests (#11220)

This commit is contained in:
Sergei Zharinov 2021-08-11 20:42:52 +03:00 committed by GitHub
parent 3d1ea66f88
commit 08aa52ccc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 24 deletions

View file

@ -1,12 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`logger/pretty-stdout formatRecord(rec) formats record 1`] = `
"TRACE: test message
\\"config\\": {\\"a\\": \\"b\\", \\"d\\": [\\"e\\", \\"f\\"]}
"
`;
exports[`logger/pretty-stdout getDetails(rec) supports a config 1`] = `
" \\"config\\": {\\"a\\": \\"b\\", \\"d\\": [\\"e\\", \\"f\\"]}
"
`;

View file

@ -7,14 +7,16 @@ describe(getName(), () => {
nottoken: 'b', nottoken: 'b',
prBody: 'foo', prBody: 'foo',
}; };
// FIXME: explicit assert condition expect(configSerializer(config)).toMatchSnapshot({
expect(configSerializer(config)).toMatchSnapshot(); prBody: '[Template]',
});
}); });
it('suppresses content', () => { it('suppresses content', () => {
const config = { const config = {
content: {}, content: {},
}; };
// FIXME: explicit assert condition expect(configSerializer(config)).toMatchSnapshot({
expect(configSerializer(config)).toMatchSnapshot(); content: '[content]',
});
}); });
}); });

View file

@ -87,8 +87,15 @@ describe(getName(), () => {
delete err.stack; delete err.stack;
// sanitize like Bunyan // sanitize like Bunyan
// FIXME: explicit assert condition expect(sanitizeValue(err)).toMatchSnapshot({
expect(sanitizeValue(err)).toMatchSnapshot(); name: 'HTTPError',
options: {
method: 'POST',
password: '***********',
url: 'https://:**redacted**@github.com/api',
username: '',
},
});
}); });
}); });
}); });

View file

@ -61,8 +61,12 @@ describe('logger', () => {
logger.error({ some: 'meta' }, 'message'); logger.error({ some: 'meta' }, 'message');
logger.warn('a warning with a p4$$w0rd'); logger.warn('a warning with a p4$$w0rd');
logger.info('ignored'); logger.info('ignored');
// FIXME: explicit assert condition expect(getProblems()).toMatchSnapshot([
expect(getProblems()).toMatchSnapshot(); { msg: 'some meta' },
{ some: 'meta', password: '***********' },
{ some: 'meta', msg: 'message' },
{ msg: 'a warning with a **redacted**' },
]);
clearProblems(); clearProblems();
expect(getProblems()).toHaveLength(0); expect(getProblems()).toHaveLength(0);
}); });

View file

@ -67,8 +67,9 @@ describe(getName(), () => {
d: ['e', 'f'], d: ['e', 'f'],
}, },
}; };
// FIXME: explicit assert condition expect(prettyStdout.getDetails(rec as any)).toEqual(
expect(prettyStdout.getDetails(rec as any)).toMatchSnapshot(); ` "config": {"a": "b", "d": ["e", "f"]}\n`
);
}); });
}); });
describe('formatRecord(rec)', () => { describe('formatRecord(rec)', () => {
@ -88,8 +89,13 @@ describe(getName(), () => {
d: ['e', 'f'], d: ['e', 'f'],
}, },
}; };
// FIXME: explicit assert condition expect(prettyStdout.formatRecord(rec)).toEqual(
expect(prettyStdout.formatRecord(rec)).toMatchSnapshot(); [
`TRACE: test message`,
` "config": {"a": "b", "d": ["e", "f"]}`,
``,
].join('\n')
);
}); });
}); });
}); });