10 Commits

Author SHA1 Message Date
2eeb4b7925 1.0.10 2020-07-25 15:47:35 +00:00
7e34275029 fix(core): update 2020-07-25 15:47:34 +00:00
c0e264146b 1.0.9 2020-07-25 15:40:11 +00:00
951772d515 fix(core): update 2020-07-25 15:40:10 +00:00
d786a3b7cd 1.0.8 2020-07-25 13:42:49 +00:00
6e0a48cc49 fix(core): update 2020-07-25 13:42:49 +00:00
88c0fc101b 1.0.7 2020-07-25 13:34:27 +00:00
6ec6869e9c fix(core): update 2020-07-25 13:34:26 +00:00
6df4f8de77 1.0.6 2020-07-05 23:35:55 +00:00
29f4529dd8 fix(core): update 2020-07-05 23:35:55 +00:00
5 changed files with 122 additions and 23 deletions

80
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@apiglobal/test-sdk",
"version": "1.0.5",
"version": "1.0.10",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -14,20 +14,64 @@
}
},
"@apiglobal/typedrequest": {
"version": "1.0.38",
"resolved": "https://verdaccio.lossless.one/@apiglobal%2ftypedrequest/-/typedrequest-1.0.38.tgz",
"integrity": "sha512-A0kFQJEadwOc9Zlnc4QvVoqL0e5zaEGye+dUDlfq3p9jvis6KbDSamG+xcGXw1HTz7BxFp66Ix73qwHUzWkHeg==",
"version": "1.0.40",
"resolved": "https://verdaccio.lossless.one/@apiglobal%2ftypedrequest/-/typedrequest-1.0.40.tgz",
"integrity": "sha512-CnYa7h6rZWe3GPf0h8F8M/LNQ1wpGRvtFnx5R6h8ukIT3agXyJIWaCpR4k8yAokSvUov4ZVwadH/FGNS1fHrfw==",
"requires": {
"@apiglobal/typedrequest-interfaces": "^1.0.13",
"@pushrocks/lik": "^4.0.13",
"@pushrocks/smartdelay": "^2.0.9",
"@pushrocks/webrequest": "^2.0.9"
"@apiglobal/typedrequest-interfaces": "^1.0.15",
"@pushrocks/isounique": "^1.0.4",
"@pushrocks/lik": "^4.0.17",
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/webrequest": "^2.0.10"
},
"dependencies": {
"@apiglobal/typedrequest-interfaces": {
"version": "1.0.15",
"resolved": "https://verdaccio.lossless.one/@apiglobal%2ftypedrequest-interfaces/-/typedrequest-interfaces-1.0.15.tgz",
"integrity": "sha512-KncX168fUQJ73FeT22Cvls41mkJmtasP8dB2s9+9/OyWZpNsCzk9NEmtdRhulW2vLQwuAbQc1eoloe7ffCmhcA=="
},
"@pushrocks/lik": {
"version": "4.0.17",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-4.0.17.tgz",
"integrity": "sha512-K5dX3k3i7iVxFMJ+IYwJRljewukJCc2zgj6+88R18/8SajVAq7ITOl3/FTbmEPFCJv5rl/LQ9FtcMynWlwSlzQ==",
"requires": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartmatch": "^1.0.7",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrx": "^2.0.17",
"@pushrocks/smarttime": "^3.0.24",
"@types/minimatch": "^3.0.3",
"symbol-tree": "^3.2.4"
}
},
"@pushrocks/smartdelay": {
"version": "2.0.10",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.10.tgz",
"integrity": "sha512-JOFpEfYiKnqcQYoUrL/jDyBDZUmlgJNm5U30MQQ3f+yci+rlFnMY5VvBBEYn5WgoX0ilwU+E15mtpDWhXcmhzg==",
"requires": {
"@pushrocks/smartpromise": "^3.0.6"
}
},
"@pushrocks/smarttime": {
"version": "3.0.24",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.24.tgz",
"integrity": "sha512-c/n0Y3CUnVNa3TnuXZ5aRc0bWj4RX7+XSjPes1J4HidU1yBOd9UOt6l08W8aPH5jMjT9Ei2jH0GsheaTGoVEYA==",
"requires": {
"@pushrocks/lik": "^4.0.13",
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartpromise": "^3.0.2",
"croner": "^1.1.23",
"dayjs": "^1.8.29",
"is-nan": "^1.3.0"
}
}
}
},
"@apiglobal/typedrequest-interfaces": {
"version": "1.0.13",
"resolved": "https://verdaccio.lossless.one/@apiglobal%2ftypedrequest-interfaces/-/typedrequest-interfaces-1.0.13.tgz",
"integrity": "sha512-3mk0mMC7unqh+Bb0mPEMwEfJcLAGl5ZjA1If/OGyk56KQOBqA2mLATS40HREeGoAEcUOHU2VCwPuU/tpSVMY/w=="
"version": "1.0.15",
"resolved": "https://verdaccio.lossless.one/@apiglobal%2ftypedrequest-interfaces/-/typedrequest-interfaces-1.0.15.tgz",
"integrity": "sha512-KncX168fUQJ73FeT22Cvls41mkJmtasP8dB2s9+9/OyWZpNsCzk9NEmtdRhulW2vLQwuAbQc1eoloe7ffCmhcA=="
},
"@babel/code-frame": {
"version": "7.10.4",
@@ -1142,8 +1186,7 @@
"@pushrocks/isounique": {
"version": "1.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fisounique/-/isounique-1.0.4.tgz",
"integrity": "sha512-P1xLsuA1+8LQpoWCo2nP2vIQXKGUl5wDWU6CD7xTDZc3uw0He5V/qCPHM5zpIZsS7IuZOxDDpWb7aFveB11tXw==",
"dev": true
"integrity": "sha512-P1xLsuA1+8LQpoWCo2nP2vIQXKGUl5wDWU6CD7xTDZc3uw0He5V/qCPHM5zpIZsS7IuZOxDDpWb7aFveB11tXw=="
},
"@pushrocks/lik": {
"version": "4.0.13",
@@ -1380,6 +1423,11 @@
"systeminformation": "^4.15.3"
}
},
"@pushrocks/smartobject": {
"version": "1.0.3",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartobject/-/smartobject-1.0.3.tgz",
"integrity": "sha512-zByvI2HHCumnoRYEWCYoDZqm9k3t/qeVo/LjmbZsdy8wVS/20Dveirexk52jEELFT3cr8IX88FvVZQ6b3pPUzQ=="
},
"@pushrocks/smartparam": {
"version": "1.1.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartparam/-/smartparam-1.1.6.tgz",
@@ -1523,9 +1571,9 @@
}
},
"@pushrocks/webrequest": {
"version": "2.0.9",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fwebrequest/-/webrequest-2.0.9.tgz",
"integrity": "sha512-cHKbVlS6j26SRzFMjvV+4hwwimXJ9NX/NnUmLmPSTZguzz6dEp1dYd+aNzGaGC8Da4ewvH7klhx7a5LI3Gv5tw==",
"version": "2.0.10",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fwebrequest/-/webrequest-2.0.10.tgz",
"integrity": "sha512-uQ8MvKclGqdLaUjah3SUsr8RplvtEUDXpFYjyO1dsHabbLWNVPQipt70CAMvS/8hOzDDD/G+dUEHIz2yZSVKNQ==",
"requires": {
"@pushrocks/smartdelay": "^2.0.9",
"@pushrocks/smartenv": "^4.0.10",

View File

@@ -1,6 +1,6 @@
{
"name": "@apiglobal/test-sdk",
"version": "1.0.5",
"version": "1.0.10",
"private": false,
"description": "an sdk for testing ag handlers",
"main": "dist_ts/index.js",
@@ -21,7 +21,10 @@
},
"dependencies": {
"@apiglobal/sdk": "^1.0.9",
"@pushrocks/smartexpress": "^3.0.73"
"@apiglobal/typedrequest": "^1.0.40",
"@apiglobal/typedrequest-interfaces": "^1.0.15",
"@pushrocks/smartexpress": "^3.0.73",
"@pushrocks/smartobject": "^1.0.3"
},
"files": [
"ts/**/*",

View File

@@ -1,7 +1,9 @@
import * as plugins from './test-sdk.plugins';
import { AgTestServer } from './test-sdk.classes.testserver';
export { AgTestServer };
export {
AgTestServer
};
let testServer: AgTestServer;
export const createTestServer = async (handlerArg: plugins.agSdk.AAgHandler<any>) => {
@@ -10,6 +12,48 @@ export const createTestServer = async (handlerArg: plugins.agSdk.AAgHandler<any>
return testServer;
};
export const testFire = <
A extends plugins.agSdk.AAgHandler<any>,
T extends plugins.typedrequestInterfaces.ITypedRequest
>(
slug: A['slug'],
methodArg: T['method'],
requestArg: T['request']
) => {
if (!testServer) {
throw new Error('you need to create and start a testServer first!');
}
if (testServer.server.serverStatus !== 'running') {
throw new Error('you need to start the testServer first!');
}
const typedRequest = new plugins.typedrequest.TypedRequest<T>(
`https://localhost:${testServer.server.options.port}`,
methodArg
);
const responsePromise = typedRequest.fire(requestArg);
const expect = async (expectedResponseArg: T['response']) => {
const actualResponse = await responsePromise;
const comparisonResult = plugins.smartobject.compareObjects(expectedResponseArg, actualResponse);
let throwErrorBool = false;
if (comparisonResult.divergingProperties.length > 0) {
console.log(`The following properties diverged:`);
console.log(comparisonResult.divergingProperties);
throwErrorBool = true;
}
if (comparisonResult.missingProperties.length > 0) {
console.log(`The following properties diverged:`);
console.log(comparisonResult.divergingProperties);
throwErrorBool = true;
}
if (throwErrorBool) {
throw new Error('response did not comply');
}
};
return {
expect
};
};
export const stopTestServer = async () => {
if (testServer) {
await testServer.stop();

View File

@@ -21,6 +21,7 @@ export class AgTestServer {
cors: true,
defaultAnswer: async () => 'apiglobal testserver',
domain: 'localhost',
port: 3000,
forceSsl: false,
});
for (const handlerArg of this.handlers) {
@@ -36,8 +37,8 @@ export class AgTestServer {
if (this.server) {
const previousServer = this.server;
this.server = null;
await this.server.startedPromise;
await this.server.stop();
await previousServer.startedPromise;
await previousServer.stop();
}
}
}

View File

@@ -1,9 +1,12 @@
// apiglobal scope
import * as agSdk from '@apiglobal/sdk';
import * as typedrequest from '@apiglobal/typedrequest';
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
export { agSdk };
export { agSdk, typedrequest, typedrequestInterfaces };
// pushrocks scope
import * as smartexpress from '@pushrocks/smartexpress';
import * as smartobject from '@pushrocks/smartobject';
export { smartexpress };
export { smartexpress, smartobject };