merge develop

This commit is contained in:
Sebastian Rindom
2021-10-15 20:09:31 +02:00
parent 10c87e8d5a
commit 4fd361fddd
207 changed files with 8699 additions and 4124 deletions

View File

@@ -1,33 +1,33 @@
const { useApi } = require("../../helpers/use-api");
const { useApi } = require("../../helpers/use-api")
const header = {
headers: {
authorization: "Bearer test_token",
},
};
}
const resolveCall = async (path, payload, header) => {
const api = useApi();
let res;
const api = useApi()
let res
try {
const resp = await api.post(path, payload, header);
res = resp.status;
const resp = await api.post(path, payload, header)
res = resp.status
} catch (expectedException) {
try {
res = expectedException.response.status;
res = expectedException.response.status
} catch (_) {
console.error(expectedException);
console.error(expectedException)
}
}
return res;
};
return res
}
const determineFail = (actual, expected, path) => {
if (expected !== actual) {
console.log(`failed at path : ${path}`);
console.log(`failed at path : ${path}`)
}
expect(actual).toEqual(expected);
};
expect(actual).toEqual(expected)
}
/**
* Allows you to wrap a Call function so that you may reuse some input values.
@@ -36,8 +36,8 @@ const determineFail = (actual, expected, path) => {
* @returns
*/
module.exports.partial = function (fun, input = {}) {
return async (remaining) => await fun({ ...remaining, ...input });
};
return async (remaining) => await fun({ ...remaining, ...input })
}
/**
* Allows you to assert a specific code result from a POST call.
@@ -51,9 +51,9 @@ module.exports.expectPostCallToReturn = async function (
payload: {},
}
) {
const res = await resolveCall(input.path, input.payload, header);
determineFail(res, input.code, input.path);
};
const res = await resolveCall(input.path, input.payload, header)
determineFail(res, input.code, input.path)
}
/**
* Allows you to assert a specific code result from multiple POST
@@ -76,10 +76,10 @@ module.exports.expectAllPostCallsToReturn = async function (
input.pathf(i),
input.payloadf ? input.payloadf(i) : {},
header
);
determineFail(res, input.code, input.pathf(i));
)
determineFail(res, input.code, input.pathf(i))
}
};
}
/**
* Allows you to retrieve a specific object the response
@@ -92,9 +92,9 @@ module.exports.expectAllPostCallsToReturn = async function (
* to the get parameter provided.
*/
module.exports.callGet = async function ({ path, get }) {
const api = useApi();
const res = await api.get(path, header);
const api = useApi()
const res = await api.get(path, header)
determineFail(res.status, 200, path);
return res?.data[get];
};
determineFail(res.status, 200, path)
return res?.data[get]
}