Skip to content

Commit

Permalink
feat(AppCtx): added unwrapCtx method to get bare ctx object
Browse files Browse the repository at this point in the history
affects: tao

this allows better interop between the AppCtx and what Kernel expects when adding/removing handlers
  • Loading branch information
eudaimos committed May 5, 2018
1 parent 5a75480 commit 9ebb558
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/tao/src/AppCtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@ export default class AppCtx extends AppCtxRoot {
get data() {
return this.datum;
}

unwrapCtx() {
return { t: this.t, a: this.a, o: this.o };
}
}
15 changes: 15 additions & 0 deletions packages/tao/src/AppCtx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ describe('AppCtx exports a class extending AppCtxRoot', () => {
});
});

describe('AppCtx can be unwrapped to a bare TAO App Context', () => {
it('should have an unwrapCtx function returning an object of the form { t, a, o } that can be used with other APIs', () => {
// Assemble
const uut = new AppCtx(TERM, ACTION, ORIENT);
// Act
const unwrapped = uut.unwrapCtx();
// Assert
expect(unwrapped).toMatchObject({
t: TERM,
a: ACTION,
o: ORIENT
});
});
});

describe('AppCtx adds data in order to define concrete Application Contexts during execution', () => {
it('should create an AppCtx with empty data', () => {
// Assemble
Expand Down

0 comments on commit 9ebb558

Please sign in to comment.