mirror of https://github.com/Seich/Beau.git
Updated tests. (#30)
With the introduction of data-driven tests in Jest 23 CLI tests could be made significantly smaller and easier to keep updated.
This commit is contained in:
parent
8fcd8b9fd3
commit
c8ff4945d6
|
|
@ -1,6 +1,6 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`List Command Should disable formatting when the flag is active. 1`] = `
|
||||
exports[`List Command with flags: --no-format 1`] = `
|
||||
Array [
|
||||
"GET anything https://example.org/anything
|
||||
",
|
||||
|
|
@ -9,7 +9,7 @@ Array [
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`List Command Should list available requests for a given file. 1`] = `
|
||||
exports[`List Command with flags: 1`] = `
|
||||
Array [
|
||||
" HTTP Verb Alias Endpoint
|
||||
",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,20 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Request Command Should output an unformatted version 1`] = `
|
||||
exports[`Request Command with flags: anything --as-json --verbose 1`] = `
|
||||
Array [
|
||||
"{\\"request\\":{\\"body\\":{\\"name\\":\\"David\\"},\\"endpoint\\":\\"https://example.org/anything\\"},\\"response\\":{\\"status\\":200,\\"headers\\":[],\\"body\\":\\"{\\\\\\"hello\\\\\\": \\\\\\"world\\\\\\"}\\"},\\"body\\":\\"{\\\\\\"hello\\\\\\": \\\\\\"world\\\\\\"}\\"}
|
||||
",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Request Command with flags: anything --as-json 1`] = `
|
||||
Array [
|
||||
"{\\"status\\":200,\\"headers\\":[],\\"body\\":\\"{\\\\\\"hello\\\\\\": \\\\\\"world\\\\\\"}\\"}
|
||||
",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Request Command with flags: anything --no-format 1`] = `
|
||||
Array [
|
||||
"200
|
||||
",
|
||||
|
|
@ -13,37 +27,9 @@ Array [
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`Request Command Should output nothing 1`] = `Array []`;
|
||||
exports[`Request Command with flags: anything --quiet 1`] = `Array []`;
|
||||
|
||||
exports[`Request Command Should output the response as json 1`] = `
|
||||
Array [
|
||||
"{\\"status\\":200,\\"headers\\":[],\\"body\\":\\"{\\\\\\"hello\\\\\\": \\\\\\"world\\\\\\"}\\"}
|
||||
",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Request Command Should output the response as json verboselly 1`] = `
|
||||
Array [
|
||||
"{\\"request\\":{\\"body\\":{\\"name\\":\\"David\\"},\\"endpoint\\":\\"https://example.org/anything\\"},\\"response\\":{\\"status\\":200,\\"headers\\":[],\\"body\\":\\"{\\\\\\"hello\\\\\\": \\\\\\"world\\\\\\"}\\"},\\"body\\":\\"{\\\\\\"hello\\\\\\": \\\\\\"world\\\\\\"}\\"}
|
||||
",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Request Command Should request the given alias 1`] = `
|
||||
Array [
|
||||
"",
|
||||
" Status Endpoint
|
||||
",
|
||||
" 200 https://example.org/anything
|
||||
",
|
||||
"
|
||||
",
|
||||
"\\"{\\"hello\\": \\"world\\"}\\"
|
||||
",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Request Command Should show all information available when being verbose 1`] = `
|
||||
exports[`Request Command with flags: anything --verbose 1`] = `
|
||||
Array [
|
||||
"",
|
||||
" Status Endpoint
|
||||
|
|
@ -69,3 +55,17 @@ Array [
|
|||
",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Request Command with flags: anything 1`] = `
|
||||
Array [
|
||||
"",
|
||||
" Status Endpoint
|
||||
",
|
||||
" 200 https://example.org/anything
|
||||
",
|
||||
"
|
||||
",
|
||||
"\\"{\\"hello\\": \\"world\\"}\\"
|
||||
",
|
||||
]
|
||||
`;
|
||||
|
|
|
|||
|
|
@ -16,13 +16,8 @@ describe('List Command', () => {
|
|||
|
||||
afterEach(() => jest.restoreAllMocks());
|
||||
|
||||
it('Should list available requests for a given file.', async () => {
|
||||
await ListCommand.run([]);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Should disable formatting when the flag is active.', async () => {
|
||||
await ListCommand.run(['--no-format']);
|
||||
test.each([[], ['--no-format']])('with flags:', async (...args) => {
|
||||
await ListCommand.run(args);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,33 +18,15 @@ describe('Request Command', () => {
|
|||
|
||||
afterEach(() => jest.restoreAllMocks());
|
||||
|
||||
it('Should request the given alias', async () => {
|
||||
await RequestCommand.run(['anything']);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Should show all information available when being verbose', async () => {
|
||||
await RequestCommand.run(['anything', '--verbose']);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Should output the response as json', async () => {
|
||||
await RequestCommand.run(['anything', '--as-json']);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Should output the response as json verboselly', async () => {
|
||||
await RequestCommand.run(['anything', '--as-json', '--verbose']);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Should output an unformatted version', async () => {
|
||||
await RequestCommand.run(['anything', '--no-format']);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Should output nothing', async () => {
|
||||
await RequestCommand.run(['anything', '--quiet']);
|
||||
test.each([
|
||||
['anything'],
|
||||
['anything', '--verbose'],
|
||||
['anything', '--as-json'],
|
||||
['anything', '--as-json', '--verbose'],
|
||||
['anything', '--no-format'],
|
||||
['anything', '--quiet']
|
||||
])('with flags:', async (...args) => {
|
||||
await RequestCommand.run(args);
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -29,7 +29,7 @@
|
|||
},
|
||||
"repository": "git@github.com:Seich/Beau.git",
|
||||
"devDependencies": {
|
||||
"jest": "^22.4.0",
|
||||
"jest": "^23.0.0",
|
||||
"strip-ansi": "^4.0.0"
|
||||
},
|
||||
"oclif": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue