Skip to content

Commit

Permalink
chore: fixing zone from which to fork a new zone (#1209)
Browse files Browse the repository at this point in the history
* chore: fixing zone from which to fork a new zone

* chore: adding tests for creating zone

Co-authored-by: Mayur Kale <mayurkale@google.com>
  • Loading branch information
obecny and mayurkale22 authored Jun 18, 2020
1 parent 28ad2ce commit 2486c3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class ZoneContextManager implements ContextManager {
* @param context A context (span) to be bind with Zone
*/
private _createZone(zoneName: string, context: unknown): Zone {
return Zone.root.fork({
return Zone.current.fork({
name: zoneName,
properties: {
[ZONE_CONTEXT_KEY]: context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,23 @@ describe('ZoneContextManager', () => {
});
});
});

it('should fork new zone from active one', () => {
const context = Context.ROOT_CONTEXT;
const rootZone = Zone.current;
contextManager.with(context, () => {
const zone1 = Zone.current;
assert.ok(zone1.parent === rootZone);
contextManager.with(context, () => {
const zone2 = Zone.current;
contextManager.with(context, () => {
const zone3 = Zone.current;
assert.ok(zone3.parent === zone2);
});
assert.ok(zone2.parent === zone1);
});
});
});
});

describe('.bind(function)', () => {
Expand Down

0 comments on commit 2486c3d

Please sign in to comment.