Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created coverage tests #7

Merged
merged 5 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/changeValidator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
node-version: 16
- name: Setup project
run: npm i
- name: Run unit tests
run: npm test
- name: Run unit tests and system test
run: npm test -- --coverage
windows:
runs-on: windows-latest
steps:
Expand All @@ -36,8 +36,8 @@ jobs:
node-version: 16
- name: Setup project
run: npm i
- name: Run unit tests
run: npm test
- name: Run unit tests and system test
run: npm test -- --coverage
mac:
runs-on: macos-latest
steps:
Expand All @@ -49,5 +49,5 @@ jobs:
node-version: 16
- name: Setup project
run: npm i
- name: Run unit tests
run: npm test
- name: Run unit tests and system test
run: npm test -- --coverage
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
package-lock.json
__test__/collection/output
__test__/collection/new_collection.json
__test__/*copy*
__test__/*copy*
coverage
new_collection.json
303 changes: 303 additions & 0 deletions __test__/__snapshots__/test-cli-unit.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Validate index.js unit tests Validate cli output messages Should show file not found error if collection doesnt exists 1`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file not found error if collection doesnt exists 2`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file not found error if collection doesnt exists 3`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file not found error if collection doesnt exists 4`] = `"exit"`;

exports[`Validate index.js unit tests Validate cli output messages Should show file not found error if collection doesnt exists 5`] = `
[MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"type": "throw",
"value": [Error: exit],
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show file not found error if collection doesnt exists 6`] = `
[MockFunction] {
"calls": Array [
Array [
"ENOENT: no such file or directory, open 'test/collection/collection.json'",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show file not found error if collection doesnt exists 7`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with custom path 1`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with custom path 2`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with custom path 3`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with custom path 4`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with custom path 5`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with default path 1`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with default path 2`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with default path 3`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with default path 4`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show file saved message correctly with default path 5`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -c argument is missing 1`] = `"exit"`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -c argument is missing 2`] = `
[MockFunction] {
"calls": Array [
Array [
1,
],
],
"results": Array [
Object {
"type": "throw",
"value": [Error: exit],
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -c argument is missing 3`] = `
[MockFunction] {
"calls": Array [
Array [
"Usage: -c \\"root/collection_name.json\\" -r \\"{{Baseurl}}/path1/path2\\" -w
\\"{{Baseurl}}/{{path}}\\" -s \\"root/new_collection_name.json\\"

Options:
--help Show help [boolean]
--version Show version number [boolean]
-c, --collection_path Path to Collection file [string] [required]
-r, --replace_url_part Replaces only the matching part of the URL
[string] [required]
-w, --with_url_part Replaces the matching part of the URL with provided
value [string] [required]
-s, --save_as path to save new collection
[string] [default: \\"root/new_<collection_name>.json\\"]",
],
Array [],
Array [
"Missing required argument: c",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -c argument is missing 4`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -r argument is missing 1`] = `"exit"`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -r argument is missing 2`] = `
[MockFunction] {
"calls": Array [
Array [
1,
],
],
"results": Array [
Object {
"type": "throw",
"value": [Error: exit],
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -r argument is missing 3`] = `
[MockFunction] {
"calls": Array [
Array [
"Usage: -c \\"root/collection_name.json\\" -r \\"{{Baseurl}}/path1/path2\\" -w
\\"{{Baseurl}}/{{path}}\\" -s \\"root/new_collection_name.json\\"

Options:
--help Show help [boolean]
--version Show version number [boolean]
-c, --collection_path Path to Collection file [string] [required]
-r, --replace_url_part Replaces only the matching part of the URL
[string] [required]
-w, --with_url_part Replaces the matching part of the URL with provided
value [string] [required]
-s, --save_as path to save new collection
[string] [default: \\"root/new_<collection_name>.json\\"]",
],
Array [],
Array [
"Missing required argument: r",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -r argument is missing 4`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -w argument is missing 1`] = `"exit"`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -w argument is missing 2`] = `
[MockFunction] {
"calls": Array [
Array [
1,
],
],
"results": Array [
Object {
"type": "throw",
"value": [Error: exit],
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -w argument is missing 3`] = `
[MockFunction] {
"calls": Array [
Array [
"Usage: -c \\"root/collection_name.json\\" -r \\"{{Baseurl}}/path1/path2\\" -w
\\"{{Baseurl}}/{{path}}\\" -s \\"root/new_collection_name.json\\"

Options:
--help Show help [boolean]
--version Show version number [boolean]
-c, --collection_path Path to Collection file [string] [required]
-r, --replace_url_part Replaces only the matching part of the URL
[string] [required]
-w, --with_url_part Replaces the matching part of the URL with provided
value [string] [required]
-s, --save_as path to save new collection
[string] [default: \\"root/new_<collection_name>.json\\"]",
],
Array [],
Array [
"Missing required argument: w",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if -w argument is missing 4`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if arguments are missing 1`] = `"exit"`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if arguments are missing 2`] = `
[MockFunction] {
"calls": Array [
Array [
1,
],
],
"results": Array [
Object {
"type": "throw",
"value": [Error: exit],
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if arguments are missing 3`] = `
[MockFunction] {
"calls": Array [
Array [
"Usage: -c \\"root/collection_name.json\\" -r \\"{{Baseurl}}/path1/path2\\" -w
\\"{{Baseurl}}/{{path}}\\" -s \\"root/new_collection_name.json\\"

Options:
--help Show help [boolean]
--version Show version number [boolean]
-c, --collection_path Path to Collection file [string] [required]
-r, --replace_url_part Replaces only the matching part of the URL
[string] [required]
-w, --with_url_part Replaces the matching part of the URL with provided
value [string] [required]
-s, --save_as path to save new collection
[string] [default: \\"root/new_<collection_name>.json\\"]",
],
Array [],
Array [
"Missing required arguments: c, r, w",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
}
`;

exports[`Validate index.js unit tests Validate cli output messages Should show help if arguments are missing 4`] = `[MockFunction]`;

exports[`Validate index.js unit tests Validate cli output messages Should throw error if exception thrown doesnt contain error code ENOENT 1`] = `"Error: Custom error"`;
Loading