Skip to content

Commit

Permalink
Education platform testing, updated test checking promise to use expe…
Browse files Browse the repository at this point in the history
…ctAsync.toBeResolvedTo(...) to improve robustness.
  • Loading branch information
barnettwilliam committed Mar 20, 2024
1 parent e7e8498 commit f096ac8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions platform/test/spec/testEducationPlatfomSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe("EducationPlatform", () => {
// types the test action functions are exepecting
const ACTION_FUNCTION_PARAM1_TYPE = "type1";
const ACTION_FUNCTION_PARAM2_TYPE = "type2";
const ACTION_FUNCTION_RESULT= "Test function result";

let platform;
let toolsManagerSpy;
Expand All @@ -176,12 +177,12 @@ describe("EducationPlatform", () => {
// platform - functionRegistry_call
spyOn (EducationPlatform.prototype, "functionRegistry_call").and.returnValue (
new Promise(function(resolve) {
resolve(true);
resolve(ACTION_FUNCTION_RESULT);
})
);
})

it("returns a promise immediately after being called", async () => {
it("returns the result via a promise", async () => {
const PARAM1_TYPE = ACTION_FUNCTION_PARAM1_TYPE;

const parameterMap = new Map (
Expand All @@ -192,10 +193,10 @@ describe("EducationPlatform", () => {
// Call the target object
const returnedResult = platform.invokeActionFunction(ACTION_FUNCTION_ID, parameterMap);

await expectAsync(returnedResult).toBePending();
await expectAsync(returnedResult).toBeResolvedTo(ACTION_FUNCTION_RESULT);
})

it("calls functionRegistry_call with the given parameter values for matching types and returns a promise", async () => {
it("calls functionRegistry_call with the given parameter values for matching types", async () => {
const PARAM1_TYPE = ACTION_FUNCTION_PARAM1_TYPE;

const parameterMap = new Map (
Expand Down

0 comments on commit f096ac8

Please sign in to comment.