@@ -34,16 +34,18 @@ module('flushDeprecations', function (hooks) {
34
34
] ) ;
35
35
36
36
let deprecationsPayload = flushDeprecations ( ) ;
37
+ let expectedConfig = {
38
+ workflow : [
39
+ { handler : 'silence' , matchId : 'first' } ,
40
+ { handler : 'silence' , matchId : 'second' } ,
41
+ ] ,
42
+ } ;
43
+
37
44
assert . strictEqual (
38
45
deprecationsPayload ,
39
46
`import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';
40
47
41
- setupDeprecationWorkflow({
42
- workflow: [
43
- { handler: "silence", matchId: "first" },
44
- { handler: "silence", matchId: "second" }
45
- ]
46
- });` ,
48
+ setupDeprecationWorkflow(${ JSON . stringify ( expectedConfig , undefined , 2 ) } );` ,
47
49
) ;
48
50
} ) ;
49
51
@@ -54,16 +56,89 @@ setupDeprecationWorkflow({
54
56
] ) ;
55
57
56
58
let deprecationsPayload = flushDeprecations ( { handler : 'log' } ) ;
59
+ let expectedConfig = {
60
+ workflow : [
61
+ { handler : 'log' , matchId : 'first' } ,
62
+ { handler : 'log' , matchId : 'second' } ,
63
+ ] ,
64
+ } ;
65
+
66
+ assert . strictEqual (
67
+ deprecationsPayload ,
68
+ `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';
69
+
70
+ setupDeprecationWorkflow(${ JSON . stringify ( expectedConfig , undefined , 2 ) } );` ,
71
+ ) ;
72
+ } ) ;
73
+
74
+ test ( 'calling flushDeprecations with existing config and no deprecations returns original config' , function ( assert ) {
75
+ let config = {
76
+ throwOnUnhandled : true ,
77
+ workflow : [ { handler : 'log' , matchId : 'existing' } ] ,
78
+ } ;
79
+ self . deprecationWorkflow . deprecationLog . messages = new Set ( [ ] ) ;
80
+
81
+ let deprecationsPayload = flushDeprecations ( { config } ) ;
82
+ assert . strictEqual (
83
+ deprecationsPayload ,
84
+ `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';
85
+
86
+ setupDeprecationWorkflow(${ JSON . stringify ( config , undefined , 2 ) } );` ,
87
+ ) ;
88
+ } ) ;
89
+
90
+ test ( 'calling flushDeprecations with existing config returns augmented config' , function ( assert ) {
91
+ let config = {
92
+ throwOnUnhandled : true ,
93
+ workflow : [ { handler : 'log' , matchId : 'existing' } ] ,
94
+ } ;
95
+ self . deprecationWorkflow . deprecationLog . messages = new Set ( [
96
+ 'first' ,
97
+ 'second' ,
98
+ ] ) ;
99
+
100
+ let deprecationsPayload = flushDeprecations ( { config } ) ;
101
+ let expectedConfig = {
102
+ throwOnUnhandled : true ,
103
+ workflow : [
104
+ { handler : 'log' , matchId : 'existing' } ,
105
+ { handler : 'silence' , matchId : 'first' } ,
106
+ { handler : 'silence' , matchId : 'second' } ,
107
+ ] ,
108
+ } ;
109
+ assert . strictEqual (
110
+ deprecationsPayload ,
111
+ `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';
112
+
113
+ setupDeprecationWorkflow(${ JSON . stringify ( expectedConfig , undefined , 2 ) } );` ,
114
+ ) ;
115
+ } ) ;
116
+
117
+ test ( 'calling flushDeprecations with existing config does not override existing deprecations' , function ( assert ) {
118
+ let config = {
119
+ throwOnUnhandled : true ,
120
+ workflow : [ { handler : 'log' , matchId : 'existing' } ] ,
121
+ } ;
122
+ self . deprecationWorkflow . deprecationLog . messages = new Set ( [
123
+ 'first' ,
124
+ 'second' ,
125
+ 'existing' ,
126
+ ] ) ;
127
+
128
+ let deprecationsPayload = flushDeprecations ( { config } ) ;
129
+ let expectedConfig = {
130
+ throwOnUnhandled : true ,
131
+ workflow : [
132
+ { handler : 'log' , matchId : 'existing' } ,
133
+ { handler : 'silence' , matchId : 'first' } ,
134
+ { handler : 'silence' , matchId : 'second' } ,
135
+ ] ,
136
+ } ;
57
137
assert . strictEqual (
58
138
deprecationsPayload ,
59
139
`import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';
60
140
61
- setupDeprecationWorkflow({
62
- workflow: [
63
- { handler: "log", matchId: "first" },
64
- { handler: "log", matchId: "second" }
65
- ]
66
- });` ,
141
+ setupDeprecationWorkflow(${ JSON . stringify ( expectedConfig , undefined , 2 ) } );` ,
67
142
) ;
68
143
} ) ;
69
144
} ) ;
0 commit comments