Skip to content

Commit 92196df

Browse files
authored
Merge pull request #123 from mixonic/mixonic/fix-limit-bug
[BUGFIX] Check the incremented count for limit
2 parents 83db9a7 + 81a581c commit 92196df

3 files changed

Lines changed: 22 additions & 17 deletions

File tree

tests/acceptance/workflow-config-test.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ module('workflow config', function (hooks) {
5959
test('deprecation logs with id matcher', (assert) => {
6060
assert.expect(1);
6161

62-
let message = 'log-id';
63-
let id = 'ember.workflow';
62+
let message = 'arbitrary-unmatched-message';
63+
let id = 'log-me';
6464
let options = {
6565
id,
6666
since: '2.0.0',
@@ -79,10 +79,11 @@ module('workflow config', function (hooks) {
7979
});
8080

8181
test('deprecation limits each id to 100 console.logs', (assert) => {
82+
assert.expect(104);
8283
let limit = 100;
8384

84-
let message = 'log-id';
85-
let id = 'ember.workflow';
85+
let message = 'log-me';
86+
let id = 'first-and-unique-to-limit-test';
8687
let options = {
8788
id,
8889
since: '2.0.0',
@@ -100,13 +101,14 @@ module('workflow config', function (hooks) {
100101
expected,
101102
'deprecation logs'
102103
);
103-
} else if (count === limit + 1) {
104-
assert.equal(
105-
passedMessage,
106-
'To avoid console overflow, this deprecation will not be logged any more in this run.'
107-
);
108-
} else {
109-
assert.ok(false, 'No further logging expected');
104+
}
105+
if (count === limit) {
106+
window.Testem.handleConsoleMessage = function (passedMessage) {
107+
assert.equal(
108+
passedMessage,
109+
'To avoid console overflow, this deprecation will not be logged any more in this run.'
110+
);
111+
};
110112
}
111113
};
112114

@@ -115,10 +117,10 @@ module('workflow config', function (hooks) {
115117
deprecate(message, false, options);
116118
}
117119

118-
assert.equal(count, limit + 1, 'logged 101 times, including final notice');
120+
assert.equal(count, limit, 'logged 100 times, including final notice');
119121

120-
let secondMessage = 'log-id2';
121-
let secondId = 'ember.workflow2';
122+
let secondMessage = 'log-me';
123+
let secondId = 'second-and-unique-to-limit-test';
122124
let secondOptions = {
123125
id: secondId,
124126
since: '2.0.0',
@@ -135,6 +137,9 @@ module('workflow config', function (hooks) {
135137
secondExpected,
136138
'second deprecation logs'
137139
);
140+
window.Testem.handleConsoleMessage = function () {
141+
assert.ok(false, 'No further logging expected');
142+
};
138143
};
139144

140145
deprecate(secondMessage, false, secondOptions);

tests/dummy/config/deprecation-workflow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ self.deprecationWorkflow.config = {
55
{ matchMessage: 'silence-me', handler: 'silence' },
66
{ matchMessage: 'log-me', handler: 'log' },
77
{ matchMessage: 'throw-me', handler: 'throw' },
8-
{ matchId: 'ember.workflow', handler: 'log' },
8+
{ matchId: 'log-me', handler: 'log' },
99
],
1010
};

vendor/ember-cli-deprecation-workflow/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ const LOG_LIMIT = 100;
4646
// no-op
4747
break;
4848
case 'log': {
49-
let key = options && options.id || message;
49+
let key = (options && options.id) || message;
5050
let count = self.deprecationWorkflow.logCounts[key] || 0;
51-
self.deprecationWorkflow.logCounts[key] = count + 1;
51+
self.deprecationWorkflow.logCounts[key] = ++count;
5252

5353
if (count <= LOG_LIMIT) {
5454
console.warn('DEPRECATION: ' + message);

0 commit comments

Comments
 (0)