Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Properly expectDeprecation when test parameter is a function #153

Merged
merged 1 commit into from
Jun 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions addon/test-helper/deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ DeprecationAssert.prototype = {
}
var assertion = this;
this.env.Ember.deprecate = function(msg, test) {
var pushDeprecation = typeof test === 'function' ? !test() : !test;
var resultOfTest = typeof test === 'function' ? test() : test;
var shouldDeprecate = !resultOfTest;

assertion.actuals = assertion.actuals || [];
if (pushDeprecation) {
assertion.actuals.push([msg, test]);
if (shouldDeprecate) {
assertion.actuals.push([msg, resultOfTest]);
}
};
},
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/deprecation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ test('expectDeprecation fires when an expected deprecation does not pass for fun
assertion.assert();
});

test('expectDeprecation fires when an expected deprecation does not pass for functions', function(){
test('expectDeprecation fires when an expected deprecation does pass for functions', function(){
expect(1);

var Ember = { deprecate: function(){} };
Expand All @@ -77,7 +77,7 @@ test('expectDeprecation fires when an expected deprecation does not pass for fun
window.expectDeprecation();

QUnit.ok = function(isOk){
originalOk(!isOk);
originalOk(isOk);
};

Ember.deprecate('some dep', function() {
Expand Down