Skip to content

Commit

Permalink
EducationPlatform testing, added test for functionRegistry_call()
Browse files Browse the repository at this point in the history
  • Loading branch information
barnettwilliam committed Mar 19, 2024
1 parent dcd4a08 commit 4e2a4b5
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions platform/test/spec/testEducationPlatfomSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export var TOKEN_SERVER_URL = "test://ts.url";
import {EducationPlatform} from"../../src/EducationPlatform.js";
import { ActionFunction } from "../../src/ActionFunction.js";
import { Panel } from "../../src/Panel.js";
import "jasmine-ajax";

describe("EducationPlatform", () => {

Expand Down Expand Up @@ -582,6 +583,63 @@ describe("EducationPlatform", () => {
})
})

describe("functionRegistry_call()", () => {
const TOOL_URL = "test://t1.url/toolfunction";
const TOOL_RESPONSE = '{ "validationResult": "PASS", "output": "Test" }';
const CONVERSION_FUNCTION_ID = "test-function-id";

const PARAMETER_1_NAME = "test-param-1";
const PARAMETER_2_NAME = "language";

const PARAMETERS_INPUT = {
[PARAMETER_1_NAME]: "Parameter 1 value",
[PARAMETER_2_NAME]: "Parameter 2 value"
};

let platform;


beforeEach(()=>{
// Setup
jasmine.Ajax.install();

platform = new EducationPlatform();

jasmine.Ajax.stubRequest(TOOL_URL).andReturn({
"responseText": TOOL_RESPONSE,
"status": 200
});

// platform - toolsManager
let toolsManagerSpy = jasmine.createSpyObj(['getActionFunction']);
toolsManagerSpy.getActionFunction.and.returnValue(new ActionFunction({
path: TOOL_URL
}));
platform.toolsManager= toolsManagerSpy;

})

afterEach(function() {
jasmine.Ajax.uninstall();
});

it("returns the result via promise", async () => {
// Call the target object
const functionResponse = platform.functionRegistry_call(CONVERSION_FUNCTION_ID, PARAMETERS_INPUT);

// Check the expected results
await expectAsync(functionResponse).toBeResolvedTo(TOOL_RESPONSE);
})

it("sends a request to the tool service url", async () => {
// Call the target object
platform.functionRegistry_call(CONVERSION_FUNCTION_ID, PARAMETERS_INPUT);

// Check the expected results
const request = jasmine.Ajax.requests.mostRecent();
expect(request.data()).toEqual( PARAMETERS_INPUT );
})
})


describe("notification", () => {
Expand Down

0 comments on commit 4e2a4b5

Please sign in to comment.