diff --git a/tests/acceptance/workflow-config-test.js b/tests/acceptance/workflow-config-test.js index 1167da4..e1e89c9 100644 --- a/tests/acceptance/workflow-config-test.js +++ b/tests/acceptance/workflow-config-test.js @@ -16,8 +16,8 @@ module('workflow config', function (hooks) { window.Testem.handleConsoleMessage = originalWarn; }); - test('deprecation silenced with string matcher', (assert) => { - deprecate('silence-me', false, { + test('deprecation silenced with message matcher', (assert) => { + deprecate('silence-strict', false, { since: 'now', until: 'forever', id: 'test', @@ -26,10 +26,10 @@ module('workflow config', function (hooks) { assert.ok(true, 'Deprecation did not raise'); }); - test('deprecation logs with string matcher', (assert) => { + test('deprecation logs with message matcher', (assert) => { assert.expect(1); - let message = 'log-me'; + let message = 'log-strict'; window.Testem.handleConsoleMessage = function (passedMessage) { assert.ok( passedMessage.indexOf('DEPRECATION: ' + message) === 0, @@ -44,10 +44,45 @@ module('workflow config', function (hooks) { }); }); + test('deprecation logs with message matcher by regex', (assert) => { + assert.expect(1); + + let message = ' foo log-match foo'; + window.Testem.handleConsoleMessage = function (passedMessage) { + assert.ok( + passedMessage.indexOf('DEPRECATION: ' + message) === 0, + 'deprecation logs' + ); + }; + deprecate(message, false, { + since: 'now', + until: 'forever', + id: 'test', + for: 'testing', + }); + }); + + test('deprecation logs with id matcher', (assert) => { + assert.expect(1); + + let message = ' foo foo'; + window.Testem.handleConsoleMessage = function (passedMessage) { + assert.ok( + passedMessage.indexOf('DEPRECATION: ' + message) === 0, + 'deprecation logs' + ); + }; + deprecate(message, false, { + since: 'now', + until: 'forever', + id: 'log-strict', + for: 'testing', + }); + }); + test('deprecation thrown with string matcher', (assert) => { - Ember.ENV.RAISE_ON_DEPRECATION = true; assert.throws(function () { - deprecate('throw-me', false, { + deprecate('throw-strict', false, { since: 'now', until: 'forever', id: 'test', @@ -59,8 +94,8 @@ module('workflow config', function (hooks) { test('deprecation logs with id matcher', (assert) => { assert.expect(1); - let message = 'log-id'; - let id = 'ember.workflow'; + let message = 'id matched (log-match)'; + let id = 'id-matched'; let options = { id, since: '2.0.0', until: '3.0.0', for: 'testing' }; let expected = `DEPRECATION: ${message}`; window.Testem.handleConsoleMessage = function (passedMessage) { @@ -74,15 +109,10 @@ module('workflow config', function (hooks) { }); test('deprecation limits each id to 100 console.logs', (assert) => { - self.deprecationWorkflow.config = { - ...self.deprecationWorkflow.config, - throwOnUnhandled: false, - }; - let limit = 100; - let message = 'log-id'; - let id = 'ember.workflow'; + let message = 'first (log-match)'; + let id = 'first-and-unique-to-100-limit-test'; let options = { id, since: '2.0.0', until: '3.0.0', for: 'testing' }; let expected = `DEPRECATION: ${message}`; @@ -112,8 +142,8 @@ module('workflow config', function (hooks) { assert.equal(count, limit + 1, 'logged 101 times, including final notice'); - let secondMessage = 'log-id2'; - let secondId = 'ember.workflow2'; + let secondMessage = 'second (log-match)'; + let secondId = 'second-and-unique-to-100-limit-test'; let secondOptions = { id: secondId, since: '2.0.0', diff --git a/tests/dummy/config/deprecation-workflow.js b/tests/dummy/config/deprecation-workflow.js index 8ffd739..b330547 100644 --- a/tests/dummy/config/deprecation-workflow.js +++ b/tests/dummy/config/deprecation-workflow.js @@ -9,11 +9,14 @@ self.deprecationWorkflow.config = { { matchId: 'ember-global', handler: 'log' }, /* - * Deprecation setup for testsActual controlled deprecations + * Deprecation setup for tests */ - { matchMessage: 'silence-me', handler: 'silence' }, - { matchMessage: 'log-me', handler: 'log' }, - { matchMessage: 'throw-me', handler: 'throw' }, - { matchId: 'ember.workflow', handler: 'log' }, + { matchId: 'silence-strict', handler: 'silence' }, + { matchMessage: 'silence-strict', handler: 'silence' }, + { matchMessage: /silence-match/, handler: 'silence' }, + { matchId: 'log-strict', handler: 'log' }, + { matchMessage: 'log-strict', handler: 'log' }, + { matchMessage: /log-match/, handler: 'log' }, + { matchMessage: 'throw-strict', handler: 'throw' }, ], }; diff --git a/tests/index.html b/tests/index.html index 3eb848d..5209b85 100644 --- a/tests/index.html +++ b/tests/index.html @@ -21,13 +21,6 @@ {{content-for "body"}} {{content-for "test-body"}} -
-