Skip to content

Commit

Permalink
fix unit tests for 'isDocumentationOutput'
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwin Dondorp committed Dec 1, 2024
1 parent 549ee7e commit 019fcb9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/unit/Output.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,42 +318,42 @@ describe("Unittests for Output.js", () => {

// ok, normal documentation case
outputData = {"host1": {"keyword": "explanation"}};
result = OutputDocumentation.isDocumentationOutput(outputData, "keyword");
result = OutputDocumentation.isDocumentationOutput(outputData, "sys.doc", "keyword");
assert.isTrue(result);

// wrong, does not match requested documentation
outputData = {"host1": {"keyword": "explanation"}};
result = OutputDocumentation.isDocumentationOutput(outputData, "another");
result = OutputDocumentation.isDocumentationOutput(outputData, "sys.doc", "another");
assert.isFalse(result);

// wrong, no resulting documentation
outputData = {"host1": {"keyword": null}};
result = OutputDocumentation.isDocumentationOutput(outputData, "keyword");
result = OutputDocumentation.isDocumentationOutput(outputData, "sys.doc", "keyword");
assert.isFalse(result);

// wrong, value is not text
outputData = {"host1": {"keyword": 123}};
result = OutputDocumentation.isDocumentationOutput(outputData, "keyword");
result = OutputDocumentation.isDocumentationOutput(outputData, "sys.doc", "keyword");
assert.isFalse(result);

// wrong, returned structure is not a dict
outputData = {"host1": ["something"]};
result = OutputDocumentation.isDocumentationOutput(outputData, "keyword");
result = OutputDocumentation.isDocumentationOutput(outputData, "sys.doc", "keyword");
assert.isFalse(result);

// wrong, returned structure is not a dict
outputData = {"host1": 123};
result = OutputDocumentation.isDocumentationOutput(outputData, "keyword");
result = OutputDocumentation.isDocumentationOutput(outputData, "sys.doc", "keyword");
assert.isFalse(result);

// wrong, returned structure is not a dict
outputData = {"host1": "hello"};
result = OutputDocumentation.isDocumentationOutput(outputData, "keyword");
result = OutputDocumentation.isDocumentationOutput(outputData, "sys.doc", "keyword");
assert.isFalse(result);

// first host ignored, second host ok
outputData = {"host1": null, "host2": {"keyword": "explanation"}};
result = OutputDocumentation.isDocumentationOutput(outputData, "keyword");
result = OutputDocumentation.isDocumentationOutput(outputData, "sys.doc", "keyword");
assert.isTrue(result);

done();
Expand Down

0 comments on commit 019fcb9

Please sign in to comment.