|
| 1 | +import { deprecate } from '@ember/debug'; |
| 2 | +import { module } from 'qunit'; |
| 3 | +import test from '../helpers/debug-test'; |
| 4 | + |
| 5 | +let originalWarn; |
| 6 | + |
| 7 | +module('flushDeprecations', function (hooks) { |
| 8 | + hooks.beforeEach(function () { |
| 9 | + originalWarn = window.Testem.handleConsoleMessage; |
| 10 | + }); |
| 11 | + |
| 12 | + hooks.afterEach(function () { |
| 13 | + window.deprecationWorkflow.deprecationLog = { messages: {} }; |
| 14 | + window.Testem.handleConsoleMessage = originalWarn; |
| 15 | + }); |
| 16 | + |
| 17 | + test('works', function (assert) { |
| 18 | + deprecate('silence-strict', false, { |
| 19 | + since: '2.0.0', |
| 20 | + until: 'forever', |
| 21 | + id: 'test', |
| 22 | + for: 'testing', |
| 23 | + }); |
| 24 | + |
| 25 | + deprecate('log-strict', false, { |
| 26 | + since: '2.0.0', |
| 27 | + until: 'forever', |
| 28 | + id: 'test', |
| 29 | + for: 'testing', |
| 30 | + }); |
| 31 | + |
| 32 | + deprecate(' foo log-match foo', false, { |
| 33 | + since: 'now', |
| 34 | + until: 'forever', |
| 35 | + id: 'test', |
| 36 | + for: 'testing', |
| 37 | + }); |
| 38 | + |
| 39 | + deprecate(' foo foo', false, { |
| 40 | + since: 'now', |
| 41 | + until: 'forever', |
| 42 | + id: 'log-strict', |
| 43 | + for: 'testing', |
| 44 | + }); |
| 45 | + |
| 46 | + deprecate('arbitrary-unmatched-message', false, { |
| 47 | + id: 'log-strict', |
| 48 | + since: '2.0.0', |
| 49 | + until: '3.0.0', |
| 50 | + for: 'testing', |
| 51 | + }); |
| 52 | + |
| 53 | + const deprecationsPayload = self.deprecationWorkflow.flushDeprecations(); |
| 54 | + |
| 55 | + assert.strictEqual( |
| 56 | + deprecationsPayload, |
| 57 | + `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; |
| 58 | +
|
| 59 | +setupDeprecationWorkflow({ |
| 60 | + workflow: [ |
| 61 | + { handler: "silence", matchId: "test" }, |
| 62 | + { handler: "silence", matchId: "log-strict" } |
| 63 | + ] |
| 64 | +});` |
| 65 | + ); |
| 66 | + }); |
| 67 | +}); |
0 commit comments