Skip to content

Commit

Permalink
Fixing #7. Ensure that deprecations and warnings that take place outs…
Browse files Browse the repository at this point in the history
…ide the test scope do not cause issues.
  • Loading branch information
Wesley Workman committed Mar 12, 2017
1 parent b72dbd8 commit b45ce23
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion addon-test-support/asserts/deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export default function() {
});

Ember.Debug.registerDeprecationHandler(function(message, options, next) {
deprecations.push({ message, options });
// It's possible for deprecations to trigger before the test has started.
if (deprecations) {
deprecations.push({ message, options });
}
next(message, options);
});

Expand Down
5 changes: 4 additions & 1 deletion addon-test-support/asserts/warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export default function() {
});

Ember.Debug.registerWarnHandler(function(message, options, next) {
warnings.push({ message, options });
// It's possible for warnings to trigger before the test has started.
if (warnings) {
warnings.push({ message, options });
}
next(message, options);
});

Expand Down
4 changes: 4 additions & 0 deletions tests/unit/deprecation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import Ember from 'ember';
import { test } from 'ember-qunit';
import moduleForAssert from '../helpers/module-for-assert';

// ............................................................
// Deprecation outside of a test. Should not cause test failures.
Ember.deprecate('Deprecation outside of a test', false, { id: 'deprecation-test', until: '3.0.0' });
// ............................................................

moduleForAssert('Deprecation Assert', { integration: false });

Expand Down
4 changes: 4 additions & 0 deletions tests/unit/warning-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import Ember from 'ember';
import { test } from 'ember-qunit';
import moduleForAssert from '../helpers/module-for-assert';

// ............................................................
// Warning outside of a test. Should not cause test failures.
Ember.warn('Warning outside of a test', false, { id: 'warning-test', until: '3.0.0' });
// ............................................................

moduleForAssert('Warning Assert', { integration: false });

Expand Down

0 comments on commit b45ce23

Please sign in to comment.