Skip to content

Commit

Permalink
Add additional tests for getContext and fix data property to be set a…
Browse files Browse the repository at this point in the history
…s an empty object
  • Loading branch information
marcellamaki committed Apr 12, 2021
1 parent 8af99b6 commit b93ba75
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/hashi/src/kolibri.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export default class Kolibri extends BaseShim {
getContext() {
return self.mediator.sendMessageAwaitReply({
event: events.CONTEXT,
data: {},
nameSpace,
});
}
Expand Down
28 changes: 27 additions & 1 deletion packages/hashi/test/kolibri.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('the kolibri hashi shim', () => {
expect(client).toHaveBeenCalledTimes(1);
});
});
it('should return a promise that resolves to aan array of metadata objects', () => {
it('should return a promise that resolves to an array of metadata objects', () => {
expect(kolibri.shim.getContentByFilter()).toBeInstanceOf(Promise);
kolibri.shim.getContentByFilter().then(() => {
expect(client).toBeInstanceOf(Array);
Expand All @@ -69,4 +69,30 @@ describe('the kolibri hashi shim', () => {
expect(kolibri.shim.navigateTo()).toBeInstanceOf(Promise);
});
});

describe('updateContext method', () => {
it('should return a promise', () => {
expect(kolibri.shim.updateContext()).toBeInstanceOf(Promise);
});
});

describe('getContext method', () => {
let response, client;
beforeEach(function() {
response = { node_id: 'abc', context: { test: 'test' } };
client = jest.fn().mockResolvedValue(response);
kolibri.shim.client = client;
});
it('should be called once', () => {
kolibri.shim.getContext().then(() => {
expect(client).toHaveBeenCalledTimes(1);
});
});
it('should return a promise that resolves to a context Object', () => {
expect(kolibri.shim.getContext()).toBeInstanceOf(Promise);
kolibri.shim.getContext().then(() => {
expect(client).toBeInstanceOf(Object);
});
});
});
});

0 comments on commit b93ba75

Please sign in to comment.