@@ -31,13 +31,6 @@ describe("PluginConfiguration", () => {
31
31
expect ( pluginConfiguration . all ( ) ) . toEqual ( { defaultKey : "defaultValue" } ) ;
32
32
} ) ;
33
33
34
- it ( "should merge the given value" , ( ) => {
35
- pluginConfiguration . set ( "key" , "value" ) ;
36
- pluginConfiguration . merge ( { some : "value" } ) ;
37
-
38
- expect ( pluginConfiguration . all ( ) ) . toEqual ( { some : "value" , key : "value" } ) ;
39
- } ) ;
40
-
41
34
it ( "should set and get the given value" , ( ) => {
42
35
pluginConfiguration . set ( "key" , "value" ) ;
43
36
@@ -59,4 +52,48 @@ describe("PluginConfiguration", () => {
59
52
it ( "should throw when using deprecated get default value argument" , ( ) => {
60
53
expect ( ( ) => pluginConfiguration . get ( "key" , "default value" ) ) . toThrow ( ) ;
61
54
} ) ;
55
+
56
+ describe ( "merge" , ( ) => {
57
+ it ( "should merge the given value" , ( ) => {
58
+ pluginConfiguration . set ( "key" , "value" ) ;
59
+ pluginConfiguration . merge ( { some : "value" } ) ;
60
+
61
+ expect ( pluginConfiguration . all ( ) ) . toEqual ( { some : "value" , key : "value" } ) ;
62
+ } ) ;
63
+
64
+ it ( "should merge nested object" , ( ) => {
65
+ pluginConfiguration . set ( "key" , {
66
+ "1" : {
67
+ "1.1" : "test" ,
68
+ } ,
69
+ } ) ;
70
+ pluginConfiguration . merge ( {
71
+ key : {
72
+ "1" : {
73
+ "1.2" : "test" ,
74
+ } ,
75
+ } ,
76
+ } ) ;
77
+
78
+ expect ( pluginConfiguration . all ( ) ) . toEqual ( {
79
+ key : {
80
+ "1" : {
81
+ "1.1" : "test" ,
82
+ "1.2" : "test" ,
83
+ } ,
84
+ } ,
85
+ } ) ;
86
+ } ) ;
87
+
88
+ it ( "should override array" , ( ) => {
89
+ pluginConfiguration . set ( "key" , [ 1 , 2 , 3 ] ) ;
90
+ pluginConfiguration . merge ( {
91
+ key : [ 3 , 4 , 5 ] ,
92
+ } ) ;
93
+
94
+ expect ( pluginConfiguration . all ( ) ) . toEqual ( {
95
+ key : [ 3 , 4 , 5 ] ,
96
+ } ) ;
97
+ } ) ;
98
+ } ) ;
62
99
} ) ;
0 commit comments