Skip to content

Commit

Permalink
e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbcgua committed Feb 22, 2020
1 parent 1ab6bf1 commit eacf1a5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
8 changes: 8 additions & 0 deletions jest.e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testMatch: [
'**/?(*.)+(e2e).(test).[jt]s?(x)',
],
// "testPathIgnorePatterns": [
// "/node_modules/",
// ]
};
32 changes: 32 additions & 0 deletions lambda.e2e.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fetch = require('node-fetch');
const pick = require('lodash.pick');

const PREFIX = '';
const HOST = 'shield.abap.space';
const functionName = 'version-shield-json';
const versionRe = /^v\d{1,3}\.\d{1,3}(\.\d{1,3})?$/i;

const getUrl = (params) => `https://${PREFIX}${HOST}/${functionName}/${params}`;

async function validateExpectations(resp) {
expect(resp.ok).toBeTruthy();
const json = await resp.json();
expect(typeof json).toBe('object');
expect(pick(json, ['schemaVersion', 'label', 'color'])).toEqual({
schemaVersion: 1,
label: 'abap package version',
color: 'orange'
});
expect(typeof json.message).toBe('string');
expect(json.message).toMatch(versionRe);
}

test('should process abap constant', async () => {
const resp = await fetch(getUrl('github/sbcgua/mockup_loader/src/zif_mockup_loader_constants.intf.abap'));
await validateExpectations(resp);
});

test('should process abap constant', async () => {
const resp = await fetch(getUrl('github/SAP-samples/abap-platform-jak/.apack-manifest.xml'));
await validateExpectations(resp);
});
6 changes: 6 additions & 0 deletions package-lock.json

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

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"test:e2e": "jest -c jest.e2e.config.js",
"lint": "eslint . lib",
"deploy-dev": "bash ./bin/deploy-dev.sh",
"deploy-prod": "bash ./bin/deploy-dev.sh",
Expand All @@ -16,10 +17,17 @@
"devDependencies": {
"eslint": "^6.8.0",
"jest": "^24.9.0",
"node-fetch": "^2.6.0",
"serverless-domain-manager": "^3.3.1"
},
"dependencies": {
"fast-xml-parser": "^3.16.0",
"lodash.pick": "^4.4.0"
},
"jest": {
"testPathIgnorePatterns": [
"/node_modules/",
"e2e"
]
}
}

0 comments on commit eacf1a5

Please sign in to comment.