Skip to content

Commit 7aa619b

Browse files
committed
chore(test): add test support and tests
1 parent c71c280 commit 7aa619b

File tree

8 files changed

+3313
-1272
lines changed

8 files changed

+3313
-1272
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/node_modules
1+
/node_modules
2+
jest

jest.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const packageJSON = require('./package.json');
2+
3+
module.exports = {
4+
errorOnDeprecated: true,
5+
moduleFileExtensions: ['ts', 'js'],
6+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.ts$',
7+
testPathIgnorePatterns: [
8+
'/node_modules/',
9+
'(/__tests__/.*|(\\.|/)(test|spec))\\.d\.ts$'
10+
],
11+
transform: {
12+
'.ts': 'ts-jest'
13+
},
14+
collectCoverage: true,
15+
coverageDirectory: '<rootDir>/jest/coverage',
16+
coveragePathIgnorePatterns: [
17+
'/__tests__/'
18+
],
19+
globals: {
20+
VERSION: packageJSON.version
21+
}
22+
};

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
"build": "rm -rf dist && webpack",
1111
"preversion": "npm run build && git add dist",
1212
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
13-
"precommit": "yarn lint",
13+
"precommit": "yarn lint && yarn test",
1414
"commitmsg": "commitlint -e $GIT_PARAMS",
15+
"test": "jest",
1516
"lint": "tslint --project tsconfig.json"
1617
},
1718
"dependencies": {
@@ -22,9 +23,14 @@
2223
"@commitlint/cli": "^7.0.0",
2324
"@commitlint/config-conventional": "^7.0.1",
2425
"@moneytree/tslint-rules": "^1.0.2",
26+
"@types/jest": "^24.0.13",
27+
"@types/node-fetch": "^2.3.3",
2528
"@types/qs": "^6.5.1",
2629
"awesome-typescript-loader": "^5.2.0",
2730
"husky": "^0.14.3",
31+
"jest": "^24.8.0",
32+
"node-fetch": "^2.5.0",
33+
"ts-jest": "^24.0.2",
2834
"tslint": "^5.16.0",
2935
"typescript": "^3.0.1",
3036
"webpack": "^4.16.3",

src/__tests__/endpoints.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import fetch from 'node-fetch';
2+
3+
import { DOMAIN, VAULT, MY_ACCOUNT } from '../endpoints';
4+
5+
describe('endpoints', () => {
6+
test('Valid Vault production domain', async () => {
7+
try {
8+
const response = await fetch(`https://${VAULT.SUBDOMAIN}.${DOMAIN}`);
9+
expect(response.status).not.toBe(404);
10+
} catch (error) {
11+
expect(error).toBeFalsy();
12+
}
13+
});
14+
15+
test('Valid Vault staging domain', async () => {
16+
try {
17+
const response = await fetch(`https://${VAULT.TEST_SUBDOMAIN}.${DOMAIN}`);
18+
expect(response.status).not.toBe(404);
19+
} catch (error) {
20+
expect(error).toBeFalsy();
21+
}
22+
});
23+
24+
test('Valid My Account production domain', async () => {
25+
try {
26+
const response = await fetch(`https://${MY_ACCOUNT.SUBDOMAIN}.${DOMAIN}`);
27+
expect(response.status).not.toBe(404);
28+
} catch (error) {
29+
expect(error).toBeFalsy();
30+
}
31+
});
32+
33+
test('Valid My Account staging domain', async () => {
34+
try {
35+
const response = await fetch(`https://${MY_ACCOUNT.TEST_SUBDOMAIN}.${DOMAIN}`);
36+
expect(response.status).not.toBe(404);
37+
} catch (error) {
38+
expect(error).toBeFalsy();
39+
}
40+
});
41+
});

0 commit comments

Comments
 (0)