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

Add more test #15

Merged
merged 1 commit into from
Nov 27, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"chalk": "^4.1.0",
"dotenv": "^8.2.0",
"jest-snapshot-serializer-ansi": "^1.0.0",
"node-fetch": "^2.6.1",
"request": "^2.88.2"
},
Expand Down
22 changes: 22 additions & 0 deletions test/__snapshots__/e2e.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`end-to-end integration prints tool version with arument -v 1`] = `
"name: testLinks
version: 1.0.0"
`;

exports[`end-to-end integration prints url information with a path 1`] = `"https://github.com is good."`;

exports[`end-to-end integration prints url information with ignore arugment 1`] = `
"This is invalid. It doesn't use http:// or https://
<html>
</html>
"
`;

exports[`end-to-end integration prints url information with path and json output 1`] = `"{\\"url\\":\\"https://github.com\\",\\"status\\":200}"`;

exports[`end-to-end integration prints url information with two path 1`] = `
"https://github.com is good.
https://github.com is good."
`;
49 changes: 49 additions & 0 deletions test/e2e.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* eslint-disable no-undef */
const execa = require('execa');
const { describe, test, expect } = require('@jest/globals');
expect.addSnapshotSerializer(require('jest-snapshot-serializer-ansi'));

describe('end-to-end integration', () => {
test('prints tool version with arument -v', async () => {
const { stdout, stderr } = await execa('node', ['index', '-v']);
expect(stdout).toMatchSnapshot();
expect(stderr).toEqual('');
});

test('prints url information with a path', async () => {
const { stdout, stderr } = await execa('node', ['index', 'test4.txt']);
expect(stdout).toMatchSnapshot();
expect(stderr).toEqual('');
});

test('prints url information with two path', async () => {
const { stdout, stderr } = await execa('node', [
'index',
'test4.txt',
'test5.html',
]);
expect(stdout).toMatchSnapshot();
expect(stderr).toEqual('');
});

test('prints url information with path and json output', async () => {
const { stdout, stderr } = await execa('node', [
'index',
'-j',
'test5.html',
]);
expect(stdout).toMatchSnapshot();
expect(stderr).toEqual('');
});

test('prints url information with ignore arugment', async () => {
const { stdout, stderr } = await execa('node', [
'index',
'-i',
'test5.html',
'test4.txt',
]);
expect(stdout).toMatchSnapshot();
expect(stderr).toEqual('');
});
});