Skip to content

Commit

Permalink
Merge pull request #15 from tianlangwu/adde2eTest
Browse files Browse the repository at this point in the history
Add End-To-End Integration Testing
  • Loading branch information
lixiaoqity committed Nov 27, 2020
2 parents a5e3335 + 8fe7ed0 commit 13b757c
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
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('');
});
});

0 comments on commit 13b757c

Please sign in to comment.