Skip to content

Commit 3c6f52d

Browse files
committed
chore: Refactor deprecationCollector to just collect raw data
1 parent 0d464a1 commit 3c6f52d

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

addon/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ export function flushDeprecations() {
5151
let messages = self.deprecationWorkflow.deprecationLog.messages;
5252
let logs = [];
5353

54-
for (let message in messages) {
55-
logs.push(messages[message]);
54+
for (let [deprecation, matcher] of Object.entries(messages)) {
55+
logs.push(
56+
` { handler: "silence", ${matcher}: ${JSON.stringify(deprecation)} }`,
57+
);
5658
}
5759

5860
let deprecations = logs.join(',\n') + '\n';
@@ -107,8 +109,7 @@ export function deprecationCollector(message, options, next) {
107109
let key = (options && options.id) || message;
108110
let matchKey = options && key === options.id ? 'matchId' : 'matchMessage';
109111

110-
self.deprecationWorkflow.deprecationLog.messages[key] =
111-
' { handler: "silence", ' + matchKey + ': ' + JSON.stringify(key) + ' }';
112+
self.deprecationWorkflow.deprecationLog.messages[key] = matchKey;
112113

113114
next(message, options);
114115
}

tests/unit/deprecation-collector-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ module('deprecationCollector', function (hooks) {
5151
);
5252

5353
assert.deepEqual(self.deprecationWorkflow.deprecationLog.messages, {
54-
first: ' { handler: "silence", matchId: "first" }',
55-
second: ' { handler: "silence", matchId: "second" }',
54+
first: 'matchId',
55+
second: 'matchId',
5656
});
5757
});
5858

@@ -120,8 +120,8 @@ module('deprecationCollector', function (hooks) {
120120
);
121121

122122
assert.deepEqual(self.deprecationWorkflow.deprecationLog.messages, {
123-
first: ' { handler: "silence", matchId: "first" }',
124-
second: ' { handler: "silence", matchId: "second" }',
123+
first: 'matchId',
124+
second: 'matchId',
125125
});
126126
});
127127
});

tests/unit/flush-deprecations-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ module('flushDeprecations', function (hooks) {
2929

3030
test('calling flushDeprecations returns string of deprecations', function (assert) {
3131
self.deprecationWorkflow.deprecationLog.messages = {
32-
first: ' { handler: "silence", matchId: "first" }',
33-
second: ' { handler: "silence", matchId: "second" }',
32+
first: 'matchId',
33+
second: 'matchId',
3434
};
3535

3636
let deprecationsPayload = flushDeprecations();

0 commit comments

Comments
 (0)