Skip to content

Commit

Permalink
Add barebones test of addInternalReferences.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccmaymay authored Oct 16, 2023
1 parent 9f44d29 commit bbca97f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src_nodejs/communication_fu.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ const {Thrift} = require('thrift');
* - tokenization: reference to the Tokenization corresponding to tokenizationId
*
* @function concrete.communication.Communication.prototype.addInternalReferences
* @returns {object} Object with references to Communication-level maps (entityForUUID, etc.),
* mainly intended for TypeScript consumers. Regular JavaScript consumers can access these
* properties directly on the Communication.
* @returns {object} Object with references to Communication-level maps (entityForUUID, entityMentionForUUID,
* sectionForUUID, sentenceForUUID, situationForUUID, situationMentionForUUID, tokenizationForUUID),
* mainly intended for TypeScript consumers. JavaScript consumers can access these maps directly
* on the Communication.
*/
Communication.prototype.addInternalReferences = function() {
this.entityForUUID = {};
Expand Down
23 changes: 23 additions & 0 deletions test_nodejs/communication_fu_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const expect = require("chai").expect;

const concrete = require("../dist_nodejs");
const commJSONData = require('../test/fixtures/dog-bites-man.concrete.json');

describe("addInternalReferences", function() {
it("Returns Communication-level maps", function() {
const comm = new Communication();
comm.initFromTJSONProtocolObject(commJSONData);
const refs = comm.addInternalReferences();
expect(
comm.addInternalReferences()
).to.have.all.keys([
"entityForUUID",
"entityMentionForUUID",
"sectionForUUID",
"sentenceForUUID",
"situationForUUID",
"situationMentionForUUID",
"tokenizationForUUID"
]);
});
});

0 comments on commit bbca97f

Please sign in to comment.