|
16 | 16 |
|
17 | 17 | import * as assert from 'assert'; |
18 | 18 | import {TagMap} from '../src'; |
| 19 | +import * as cls from '../src/internal/cls'; |
19 | 20 | import * as tagger from '../src/tags/tagger'; |
20 | 21 |
|
| 22 | +const contextManager = cls.getNamespace(); |
| 23 | + |
21 | 24 | describe('tagger()', () => { |
22 | 25 | const tags1 = new TagMap(); |
23 | 26 | tags1.set({name: 'key1'}, {value: 'value1'}); |
@@ -54,57 +57,68 @@ describe('tagger()', () => { |
54 | 57 | expectedTagsFrom1n3n4.set({name: 'key6'}, {value: 'value6'}); |
55 | 58 |
|
56 | 59 | it('should return empty current tag context', () => { |
57 | | - tagger.withTagContext(tagger.EMPTY_TAG_MAP, () => { |
| 60 | + tagger.withTagContext(contextManager, tagger.EMPTY_TAG_MAP, () => { |
58 | 61 | assert.deepStrictEqual( |
59 | | - tagger.getCurrentTagContext(), tagger.EMPTY_TAG_MAP); |
| 62 | + tagger.getCurrentTagContext(contextManager), tagger.EMPTY_TAG_MAP); |
60 | 63 | }); |
61 | 64 | }); |
62 | 65 |
|
63 | 66 | it('should set current tag context', () => { |
64 | | - tagger.withTagContext(tags1, () => { |
65 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tags1); |
| 67 | + tagger.withTagContext(contextManager, tags1, () => { |
| 68 | + assert.deepStrictEqual( |
| 69 | + tagger.getCurrentTagContext(contextManager), tags1); |
66 | 70 | }); |
67 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tagger.EMPTY_TAG_MAP); |
| 71 | + assert.deepStrictEqual( |
| 72 | + tagger.getCurrentTagContext(contextManager), tagger.EMPTY_TAG_MAP); |
68 | 73 | }); |
69 | 74 |
|
70 | 75 | it('should set nested current tag context', () => { |
71 | | - tagger.withTagContext(tags1, () => { |
72 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tags1); |
| 76 | + tagger.withTagContext(contextManager, tags1, () => { |
| 77 | + assert.deepStrictEqual( |
| 78 | + tagger.getCurrentTagContext(contextManager), tags1); |
73 | 79 |
|
74 | | - tagger.withTagContext(tags2, () => { |
| 80 | + tagger.withTagContext(contextManager, tags2, () => { |
75 | 81 | assert.deepStrictEqual( |
76 | | - tagger.getCurrentTagContext(), expectedMergedTags); |
| 82 | + tagger.getCurrentTagContext(contextManager), expectedMergedTags); |
77 | 83 | }); |
78 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tags1); |
| 84 | + assert.deepStrictEqual( |
| 85 | + tagger.getCurrentTagContext(contextManager), tags1); |
79 | 86 | }); |
80 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tagger.EMPTY_TAG_MAP); |
| 87 | + assert.deepStrictEqual( |
| 88 | + tagger.getCurrentTagContext(contextManager), tagger.EMPTY_TAG_MAP); |
81 | 89 | }); |
82 | 90 |
|
83 | 91 | it('should resolve tag conflicts', () => { |
84 | | - tagger.withTagContext(tags1, () => { |
85 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tags1); |
| 92 | + tagger.withTagContext(contextManager, tags1, () => { |
| 93 | + assert.deepStrictEqual( |
| 94 | + tagger.getCurrentTagContext(contextManager), tags1); |
86 | 95 |
|
87 | | - tagger.withTagContext(tags3, () => { |
| 96 | + tagger.withTagContext(contextManager, tags3, () => { |
88 | 97 | assert.deepStrictEqual( |
89 | | - tagger.getCurrentTagContext(), expectedTagsFrom1n3); |
| 98 | + tagger.getCurrentTagContext(contextManager), expectedTagsFrom1n3); |
90 | 99 |
|
91 | | - tagger.withTagContext(tags4, () => { |
| 100 | + tagger.withTagContext(contextManager, tags4, () => { |
92 | 101 | assert.deepStrictEqual( |
93 | | - tagger.getCurrentTagContext(), expectedTagsFrom1n3n4); |
| 102 | + tagger.getCurrentTagContext(contextManager), |
| 103 | + expectedTagsFrom1n3n4); |
94 | 104 | }); |
95 | 105 | }); |
96 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tags1); |
| 106 | + assert.deepStrictEqual( |
| 107 | + tagger.getCurrentTagContext(contextManager), tags1); |
97 | 108 | }); |
98 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tagger.EMPTY_TAG_MAP); |
| 109 | + assert.deepStrictEqual( |
| 110 | + tagger.getCurrentTagContext(contextManager), tagger.EMPTY_TAG_MAP); |
99 | 111 | }); |
100 | 112 |
|
101 | 113 | it('should clear current tag context', () => { |
102 | | - tagger.withTagContext(tags1, () => { |
103 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tags1); |
104 | | - tagger.clear(); |
| 114 | + tagger.withTagContext(contextManager, tags1, () => { |
| 115 | + assert.deepStrictEqual( |
| 116 | + tagger.getCurrentTagContext(contextManager), tags1); |
| 117 | + tagger.clear(contextManager); |
105 | 118 | assert.deepStrictEqual( |
106 | | - tagger.getCurrentTagContext(), tagger.EMPTY_TAG_MAP); |
| 119 | + tagger.getCurrentTagContext(contextManager), tagger.EMPTY_TAG_MAP); |
107 | 120 | }); |
108 | | - assert.deepStrictEqual(tagger.getCurrentTagContext(), tagger.EMPTY_TAG_MAP); |
| 121 | + assert.deepStrictEqual( |
| 122 | + tagger.getCurrentTagContext(contextManager), tagger.EMPTY_TAG_MAP); |
109 | 123 | }); |
110 | 124 | }); |
0 commit comments