This commit is contained in:
Sergio Díaz 2018-05-29 21:23:45 +00:00 committed by GitHub
commit 28859fa0c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1914 additions and 3535 deletions

View File

@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // 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 [ Array [
"GET anything https://example.org/anything "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 [ Array [
" HTTP Verb Alias Endpoint " HTTP Verb Alias Endpoint
", ",

View File

@ -1,6 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // 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 [ Array [
"200 "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`] = ` exports[`Request Command with flags: anything --verbose 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`] = `
Array [ Array [
"", "",
" Status Endpoint " Status Endpoint
@ -69,3 +55,17 @@ Array [
", ",
] ]
`; `;
exports[`Request Command with flags: anything 1`] = `
Array [
"",
" Status Endpoint
",
" 200 https://example.org/anything
",
"
",
"\\"{\\"hello\\": \\"world\\"}\\"
",
]
`;

View File

@ -16,13 +16,8 @@ describe('List Command', () => {
afterEach(() => jest.restoreAllMocks()); afterEach(() => jest.restoreAllMocks());
it('Should list available requests for a given file.', async () => { test.each([[], ['--no-format']])('with flags:', async (...args) => {
await ListCommand.run([]); await ListCommand.run(args);
expect(result).toMatchSnapshot();
});
it('Should disable formatting when the flag is active.', async () => {
await ListCommand.run(['--no-format']);
expect(result).toMatchSnapshot(); expect(result).toMatchSnapshot();
}); });
}); });

View File

@ -18,33 +18,15 @@ describe('Request Command', () => {
afterEach(() => jest.restoreAllMocks()); afterEach(() => jest.restoreAllMocks());
it('Should request the given alias', async () => { test.each([
await RequestCommand.run(['anything']); ['anything'],
expect(result).toMatchSnapshot(); ['anything', '--verbose'],
}); ['anything', '--as-json'],
['anything', '--as-json', '--verbose'],
it('Should show all information available when being verbose', async () => { ['anything', '--no-format'],
await RequestCommand.run(['anything', '--verbose']); ['anything', '--quiet']
expect(result).toMatchSnapshot(); ])('with flags:', async (...args) => {
}); await RequestCommand.run(args);
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']);
expect(result).toMatchSnapshot(); expect(result).toMatchSnapshot();
}); });

5321
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,27 +9,28 @@
"test": "jest", "test": "jest",
"test:coverage": "jest --coverage ./src" "test:coverage": "jest --coverage ./src"
}, },
"files": ["./src/*"],
"dependencies": { "dependencies": {
"@oclif/command": "^1.4.16", "@oclif/command": "^1.4.30",
"@oclif/config": "^1.6.13", "@oclif/config": "^1.6.21",
"@oclif/plugin-help": "^1.2.5", "@oclif/plugin-help": "^2.0.0",
"@oclif/plugin-warn-if-update-available": "^1.3.6", "@oclif/plugin-warn-if-update-available": "^1.3.9",
"cli-color": "^1.1.0", "cli-color": "^1.1.0",
"clui": "^0.3.1", "clui": "^0.3.1",
"deepmerge": "^2.1.0", "deepmerge": "^2.1.1",
"dotenv": "^5.0.1", "dotenv": "^5.0.1",
"joi": "^13.2.0",
"globby": "^8.0.1", "globby": "^8.0.1",
"is-plain-object": "^2.0.4", "is-plain-object": "^2.0.4",
"joi": "^13.3.0",
"js-yaml": "^3.11.0", "js-yaml": "^3.11.0",
"jsome": "^2.5.0", "jsome": "^2.5.0",
"request": "^2.85.0", "request": "^2.87.0",
"request-promise-native": "^1.0.5", "request-promise-native": "^1.0.5",
"requireg": "^0.1.6" "requireg": "^0.1.6"
}, },
"repository": "git@github.com:Seich/Beau.git", "repository": "git@github.com:Seich/Beau.git",
"devDependencies": { "devDependencies": {
"jest": "^22.4.0", "jest": "^23.0.0",
"strip-ansi": "^4.0.0" "strip-ansi": "^4.0.0"
}, },
"oclif": { "oclif": {