Skip to content

Commit

Permalink
Move test to map/map-test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bgando committed Aug 30, 2017
1 parent 152705e commit 292b1a5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 39 deletions.
39 changes: 0 additions & 39 deletions define-test.js
Expand Up @@ -5,8 +5,6 @@ var CanList = require("can-define/list/list");
var canBatch = require("can-event/batch/batch");
var each = require("can-util/js/each/each");
var canSymbol = require("can-symbol");
var canDev = require("can-util/js/dev/dev");
var DefineMap = require("can-define/map/map");

QUnit.module("can-define");

Expand Down Expand Up @@ -1370,40 +1368,3 @@ QUnit.test('define() should add a CID (#246)', function() {
var g = new Greeting();
QUnit.ok(g._cid, "should have a CID property");
});

if(System.env.indexOf("production") < 0) {
QUnit.test('Setting a value with an object type generates a warning (#148)', function() {
QUnit.expect(2);
var oldwarn = canDev.warn;
canDev.warn = function(mesg) {
QUnit.equal(mesg, "The value for options is set to an object. This will be shared by all instances of the DefineMap. Use a function that returns the object instead.", "Warning is expected message");
};
//should issue a warning
DefineMap.extend({
options: {
value: {}
}
});
//should issue a warning
DefineMap.extend({
options: {
value: []
}
});

//should not issue a warning
DefineMap.extend({
options: {
value: function(){}
}
});

//should not issue a warning
DefineMap.extend({
options: {
value: 2
}
});
canDev.warn = oldwarn;
});
}
38 changes: 38 additions & 0 deletions map/map-test.js
Expand Up @@ -8,6 +8,7 @@ var compute = require("can-compute");
var assign = require("can-util/js/assign/assign");
var canReflect = require("can-reflect");
var isPlainObject = require("can-util/js/is-plain-object/is-plain-object");
var canDev = require("can-util/js/dev/dev");

var sealWorks = (function() {
try {
Expand Down Expand Up @@ -836,3 +837,40 @@ QUnit.test("non-Object constructor", function() {
QUnit.ok(!isPlainObject(new DefineMap()), "instance of DefineMap is not a plain object");
QUnit.ok(!isPlainObject(new Constructor()), "instance of extended DefineMap is not a plain object");
});

if(System.env.indexOf("production") < 0) {
QUnit.test('Setting a value with an object type generates a warning (#148)', function() {
QUnit.expect(2);
var oldwarn = canDev.warn;
canDev.warn = function(mesg) {
QUnit.equal(mesg, "The value for options is set to an object. This will be shared by all instances of the DefineMap. Use a function that returns the object instead.", "Warning is expected message");
};
//should issue a warning
DefineMap.extend({
options: {
value: {}
}
});
//should issue a warning
DefineMap.extend({
options: {
value: []
}
});

//should not issue a warning
DefineMap.extend({
options: {
value: function(){}
}
});

//should not issue a warning
DefineMap.extend({
options: {
value: 2
}
});
canDev.warn = oldwarn;
});
}

0 comments on commit 292b1a5

Please sign in to comment.