@@ -16,7 +16,7 @@ test('can set property', () => {
16
16
expect ( actualValue ) . toBe ( expectedValue ) ;
17
17
} ) ;
18
18
19
- test ( 'putDimension adds key to dimension and sets the dimension as a property' , ( ) => {
19
+ test ( 'putDimensions adds key to dimension and sets the dimension as a property' , ( ) => {
20
20
// arrange
21
21
const context = MetricsContext . empty ( ) ;
22
22
const dimension = faker . random . word ( ) ;
@@ -29,51 +29,46 @@ test('putDimension adds key to dimension and sets the dimension as a property',
29
29
expect ( context . getDimensions ( ) [ 0 ] ) . toStrictEqual ( expectedDimension ) ;
30
30
} ) ;
31
31
32
- test ( 'putDimension will not duplicate dimensions ' , ( ) => {
32
+ test ( 'putDimensions accepts multiple unique dimension sets ' , ( ) => {
33
33
// arrange
34
34
const context = MetricsContext . empty ( ) ;
35
- const dimension = faker . random . word ( ) ;
36
- const expectedDimension = { dimension } ;
35
+ const expectedDimension1 = { d1 : faker . random . word ( ) , d2 : faker . random . word ( ) } ;
36
+ const expectedDimension2 = { d2 : faker . random . word ( ) , d3 : faker . random . word ( ) } ;
37
37
38
38
// act
39
- context . putDimensions ( { dimension } ) ;
40
- context . putDimensions ( { dimension } ) ;
39
+ context . putDimensions ( expectedDimension1 ) ;
40
+ context . putDimensions ( expectedDimension2 ) ;
41
41
42
42
// assert
43
- expect ( context . getDimensions ( ) . length ) . toBe ( 1 ) ;
44
- expect ( context . getDimensions ( ) [ 0 ] ) . toStrictEqual ( expectedDimension ) ;
43
+ expect ( context . getDimensions ( ) . length ) . toBe ( 2 ) ;
44
+ expect ( context . getDimensions ( ) [ 0 ] ) . toStrictEqual ( expectedDimension1 ) ;
45
+ expect ( context . getDimensions ( ) [ 1 ] ) . toStrictEqual ( expectedDimension2 ) ;
45
46
} ) ;
46
47
47
- test ( 'putDimension will not duplicate dimensions, multiple in different order ' , ( ) => {
48
+ test ( 'putDimensions will not duplicate dimensions' , ( ) => {
48
49
// arrange
49
50
const context = MetricsContext . empty ( ) ;
50
51
const dimension1 = faker . random . word ( ) ;
51
52
const dimension2 = faker . random . word ( ) ;
52
- const expectedDimension = { dimension1, dimension2 } ;
53
+ const expectedDimension1 = { dimension1 } ;
54
+ const expectedDimension2 = { dimension1, dimension2 } ;
55
+ const expectedDimension3 = { dimension2 } ;
53
56
54
57
// act
58
+ context . putDimensions ( { dimension1 } ) ;
55
59
context . putDimensions ( { dimension1, dimension2 } ) ;
56
60
context . putDimensions ( { dimension2, dimension1 } ) ;
61
+ context . putDimensions ( { dimension2 } ) ;
62
+ context . putDimensions ( { dimension1 } ) ;
63
+ context . putDimensions ( { dimension1, dimension2 } ) ;
64
+ context . putDimensions ( { dimension2, dimension1 } ) ;
65
+ context . putDimensions ( { dimension2 } ) ;
57
66
58
67
// assert
59
- expect ( context . getDimensions ( ) . length ) . toBe ( 1 ) ;
60
- expect ( context . getDimensions ( ) [ 0 ] ) . toStrictEqual ( expectedDimension ) ;
61
- } ) ;
62
-
63
- test ( 'putDimension accepts multiple unique dimension sets' , ( ) => {
64
- // arrange
65
- const context = MetricsContext . empty ( ) ;
66
- const expectedDimension1 = { d1 : faker . random . word ( ) , d2 : faker . random . word ( ) } ;
67
- const expectedDimension2 = { d2 : faker . random . word ( ) , d3 : faker . random . word ( ) } ;
68
-
69
- // act
70
- context . putDimensions ( expectedDimension1 ) ;
71
- context . putDimensions ( expectedDimension2 ) ;
72
-
73
- // assert
74
- expect ( context . getDimensions ( ) . length ) . toBe ( 2 ) ;
68
+ expect ( context . getDimensions ( ) . length ) . toBe ( 3 ) ;
75
69
expect ( context . getDimensions ( ) [ 0 ] ) . toStrictEqual ( expectedDimension1 ) ;
76
70
expect ( context . getDimensions ( ) [ 1 ] ) . toStrictEqual ( expectedDimension2 ) ;
71
+ expect ( context . getDimensions ( ) [ 2 ] ) . toStrictEqual ( expectedDimension3 ) ;
77
72
} ) ;
78
73
79
74
test ( 'getDimensions returns default dimensions if custom dimensions not set' , ( ) => {
@@ -201,5 +196,5 @@ test('createCopyWithContext copies shouldUseDefaultDimensions', () => {
201
196
202
197
// assert
203
198
expect ( newContext ) . not . toBe ( context ) ;
204
- expect ( newContext . getDimensions ( ) ) . toEqual ( [ ] )
199
+ expect ( newContext . getDimensions ( ) ) . toEqual ( [ ] ) ;
205
200
} ) ;
0 commit comments