Skip to content

Commit

Permalink
Guard dev warning test behind System.env check
Browse files Browse the repository at this point in the history
  • Loading branch information
bmomberger-bitovi committed Aug 30, 2017
1 parent 1448610 commit eeb2aab
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions define-test.js
Expand Up @@ -1370,40 +1370,44 @@ QUnit.test('define() should add a CID (#246)', function() {
QUnit.ok(g._cid, "should have a CID property");
});

QUnit.test("warn on using a Constructor for small-t type definintions", function() {
expect(2);
var oldWarn = canDev.warn;
canDev.warn = function(mesg) {
QUnit.equal(mesg, "can-define: the definition for currency uses a constructor for \"type\". Did you mean \"Type\"?");
};
if (System.env.indexOf("production") < 0) {

function Currency() {
return this;
}
Currency.prototype = {
symbol: "USD"
};
QUnit.test("warn on using a Constructor for small-t type definintions", function() {
expect(2);
var oldWarn = canDev.warn;
canDev.warn = function(mesg) {
QUnit.equal(mesg, "can-define: the definition for currency uses a constructor for \"type\". Did you mean \"Type\"?");
};

function VM() {}
define(VM.prototype, {
currency: {
type: Currency, // should be `Type: Currency`
value: new Currency({})
}
});
function Currency() {
return this;
}
Currency.prototype = {
symbol: "USD"
};

canDev.warn = function(mesg) {
QUnit.equal(mesg, "can-define: the definition for currency on VM2 uses a constructor for \"type\". Did you mean \"Type\"?");
};
function VM() {}
define(VM.prototype, {
currency: {
type: Currency, // should be `Type: Currency`
value: new Currency({})
}
});

canDev.warn = function(mesg) {
QUnit.equal(mesg, "can-define: the definition for currency on VM2 uses a constructor for \"type\". Did you mean \"Type\"?");
};

function VM2() {}
VM2.shortName = "VM2";
define(VM2.prototype, {
currency: {
type: Currency, // should be `Type: Currency`
value: new Currency({})
}
});

function VM2() {}
VM2.shortName = "VM2";
define(VM2.prototype, {
currency: {
type: Currency, // should be `Type: Currency`
value: new Currency({})
}
canDev.warn = oldWarn;
});

canDev.warn = oldWarn;
});
}

0 comments on commit eeb2aab

Please sign in to comment.