Skip to content

Commit

Permalink
Updated the 'sets tools URLs correctly' test to check all provided ur…
Browse files Browse the repository at this point in the history
…ls are as expected with multiple URLs input, combined similar test 'the tool configuration that is parsed and stored has the expected keys', and checked for the expected complete panel definition object in test 'returns the correct object for an existing panel definition id'
  • Loading branch information
barnettwilliam committed Mar 6, 2024
1 parent c030dfe commit 0f8cd9c
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions platform/test/spec/testToolManagerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ describe("ToolManager", () => {

describe("initialisation", () => {
// Setup
const TOOL_URLS= [ "test://t1.url/tool-config.json" ];
const TOOL_URLS= [ "test://t1.url/tool-config.json",
"test://t2.url/tool-config.json",
"test://t3.url/tool-config.json" ];
let tm;

beforeEach( () => {
Expand All @@ -38,10 +40,12 @@ describe("ToolManager", () => {
it("sets tools URLs correctly", () => {
// Call the target object
tm.setToolsUrls(TOOL_URLS);

// Check the expected results
for (const t in tm.toolsUrls){
expect(tm.toolsUrls[t].url).toEqual(TOOL_URLS[t]);
expect(tm.toolsUrls).toHaveSize(TOOL_URLS.length);

for (const i in TOOL_URLS){
expect(tm.toolsUrls[i].url).toEqual(TOOL_URLS[i]);
}
})

Expand All @@ -66,19 +70,6 @@ describe("ToolManager", () => {
const TOOL1_ID= "tool-1"

expect(tm.tools[TOOL1_ID]).toBeInstanceOf(Object);
})

it("the tool configuration that is parsed and stored has the expected keys", () => {
jasmine.Ajax.stubRequest('test://t1.url/tool-config.json').andReturn({
"responseText": TOOL_1PANELDEF_1FUNCTION,
"status": 200
});

// Call the target object
tm.setToolsUrls(TOOL_URLS);

// Check the expected results
const TOOL1_ID= "tool-1"
const EXPECTED_TOOL_KEYS = ["id", "name","version", "author", "homepage", "functions", "panelDefs"];

const storedToolKeys = Object.keys(tm.tools[TOOL1_ID]);
Expand Down Expand Up @@ -118,8 +109,11 @@ describe("ToolManager", () => {
const foundPanelDef= tm.getPanelDefinition(PANEL_DEF_ID);

// Check the expected results
const toolConfig = JSON.parse(TOOL_1PANELDEF_1FUNCTION);
const expectedPanelDef = toolConfig.tool.panelDefs[0];

expect(foundPanelDef).toBeInstanceOf(Object);
expect(foundPanelDef.id).toEqual(PANEL_DEF_ID);
expect(foundPanelDef).toEqual(expectedPanelDef);
})

it ("returns null for a panel definition id that does not exist", () => {
Expand Down

0 comments on commit 0f8cd9c

Please sign in to comment.