can-map-define
Advanced tools
Comparing version 4.3.7 to 4.3.8
@@ -14,3 +14,3 @@ /* jshint asi: false */ | ||
// remove, type, default | ||
QUnit.test('basics set', function() { | ||
QUnit.test('basics set', function(assert) { | ||
var Defined = CanMap.extend({ | ||
@@ -29,3 +29,3 @@ define: { | ||
equal(def.attr("prop"), "foobar", "setter works"); | ||
assert.equal(def.attr("prop"), "foobar", "setter works"); | ||
@@ -45,7 +45,7 @@ Defined = CanMap.extend({ | ||
equal(def.attr("prop"), "foobar", "setter callback works"); | ||
assert.equal(def.attr("prop"), "foobar", "setter callback works"); | ||
}); | ||
QUnit.test("basics remove", function() { | ||
QUnit.test("basics remove", function(assert) { | ||
var ViewModel = CanMap.extend({ | ||
@@ -101,4 +101,4 @@ define: { | ||
} | ||
equal(attr, events[eventCount++], "got correct attribute"); | ||
ok(ev.batchNum && ev.batchNum === batchNum, "batched"); | ||
assert.equal(attr, events[eventCount++], "got correct attribute"); | ||
assert.ok(ev.batchNum && ev.batchNum === batchNum, "batched"); | ||
}); | ||
@@ -166,5 +166,5 @@ | ||
QUnit.test("basic type", function() { | ||
QUnit.test("basic type", function(assert) { | ||
expect(6); | ||
assert.expect(6); | ||
@@ -195,3 +195,3 @@ var Typer = CanMap.extend({ | ||
var t = new Typer(); | ||
deepEqual(CanMap.keys(t), ["arrayWithAddedItem", "listWithAddedItem"], "defined keys"); | ||
assert.deepEqual(CanMap.keys(t), ["arrayWithAddedItem", "listWithAddedItem"], "defined keys"); | ||
@@ -201,12 +201,12 @@ var array = []; | ||
deepEqual(array, ["item"], "updated array"); | ||
equal(t.attr("arrayWithAddedItem"), array, "leave value as array"); | ||
assert.deepEqual(array, ["item"], "updated array"); | ||
assert.equal(t.attr("arrayWithAddedItem"), array, "leave value as array"); | ||
t.attr("listWithAddedItem", []); | ||
ok(t.attr("listWithAddedItem") instanceof List, "convert to List"); | ||
equal(t.attr("listWithAddedItem").attr(0), "item", "has item in it"); | ||
assert.ok(t.attr("listWithAddedItem") instanceof List, "convert to List"); | ||
assert.equal(t.attr("listWithAddedItem").attr(0), "item", "has item in it"); | ||
t.bind("change", function(ev, attr) { | ||
equal(attr, "listWithAddedItem.1", "got a bubbling event"); | ||
assert.equal(attr, "listWithAddedItem.1", "got a bubbling event"); | ||
}); | ||
@@ -218,3 +218,3 @@ | ||
QUnit.test("basic Type", function() { | ||
QUnit.test("basic Type", function(assert) { | ||
var Foo = function(name) { | ||
@@ -238,3 +238,3 @@ this.name = name; | ||
}); | ||
equal(t.attr("foo").getName(), "Justin", "correctly created an instance"); | ||
assert.equal(t.attr("foo").getName(), "Justin", "correctly created an instance"); | ||
@@ -245,7 +245,7 @@ var brian = new Foo("brian"); | ||
equal(t.attr("foo"), brian, "same instances"); | ||
assert.equal(t.attr("foo"), brian, "same instances"); | ||
}); | ||
QUnit.test("type converters", function() { | ||
QUnit.test("type converters", function(assert) { | ||
@@ -285,17 +285,17 @@ var Typer = CanMap.extend({ | ||
ok(t.attr("date") instanceof Date, "converted to date"); | ||
assert.ok(t.attr("date") instanceof Date, "converted to date"); | ||
equal(t.attr("string"), '5', "converted to string"); | ||
assert.equal(t.attr("string"), '5', "converted to string"); | ||
equal(t.attr("number"), 5, "converted to number"); | ||
assert.equal(t.attr("number"), 5, "converted to number"); | ||
equal(t.attr("boolean"), false, "converted to boolean"); | ||
assert.equal(t.attr("boolean"), false, "converted to boolean"); | ||
equal(t.attr("htmlbool"), true, "converted to htmlbool"); | ||
assert.equal(t.attr("htmlbool"), true, "converted to htmlbool"); | ||
equal(t.attr("leaveAlone"), obj, "left as object"); | ||
assert.equal(t.attr("leaveAlone"), obj, "left as object"); | ||
t.attr({ | ||
'number': '15' | ||
}); | ||
ok(t.attr("number") === 15, "converted to number"); | ||
assert.ok(t.attr("number") === 15, "converted to number"); | ||
@@ -305,3 +305,3 @@ }); | ||
QUnit.test("basics value", function() { | ||
QUnit.test("basics value", function(assert) { | ||
var Typer = CanMap.extend({ | ||
@@ -315,3 +315,3 @@ define: { | ||
equal(new Typer().attr('prop'), "foo", "value is used as default value"); | ||
assert.equal(new Typer().attr('prop'), "foo", "value is used as default value"); | ||
@@ -332,4 +332,4 @@ | ||
t2 = new Typer2(); | ||
ok(t1.attr("prop") !== t2.attr("prop"), "different array instances"); | ||
ok(Array.isArray(t1.attr("prop")), "its an array"); | ||
assert.ok(t1.attr("prop") !== t2.attr("prop"), "different array instances"); | ||
assert.ok(Array.isArray(t1.attr("prop")), "its an array"); | ||
@@ -339,3 +339,3 @@ | ||
QUnit.test("basics Value", function() { | ||
QUnit.test("basics Value", function(assert) { | ||
@@ -353,4 +353,4 @@ var Typer = CanMap.extend({ | ||
t2 = new Typer(); | ||
ok(t1.attr("prop") !== t2.attr("prop"), "different array instances"); | ||
ok(Array.isArray(t1.attr("prop")), "its an array"); | ||
assert.ok(t1.attr("prop") !== t2.attr("prop"), "different array instances"); | ||
assert.ok(Array.isArray(t1.attr("prop")), "its an array"); | ||
@@ -361,3 +361,3 @@ | ||
QUnit.test("setter with no arguments and returns undefined does the default behavior, the setter is for side effects only", function() { | ||
QUnit.test("setter with no arguments and returns undefined does the default behavior, the setter is for side effects only", function(assert) { | ||
@@ -378,3 +378,3 @@ var Typer = CanMap.extend({ | ||
deepEqual(t.attr(), { | ||
assert.deepEqual(t.attr(), { | ||
foo: "bar", | ||
@@ -387,3 +387,3 @@ prop: false | ||
QUnit.test("type happens before the set", function() { | ||
QUnit.test("type happens before the set", function(assert) { | ||
var MyMap = CanMap.extend({ | ||
@@ -394,3 +394,3 @@ define: { | ||
set: function(newValue) { | ||
equal(typeof newValue, "number", "got a number"); | ||
assert.equal(typeof newValue, "number", "got a number"); | ||
return newValue + 1; | ||
@@ -405,7 +405,7 @@ } | ||
equal(map.attr("prop"), 6, "number"); | ||
assert.equal(map.attr("prop"), 6, "number"); | ||
}); | ||
QUnit.test("getter and setter work", function() { | ||
expect(5); | ||
QUnit.test("getter and setter work", function(assert) { | ||
assert.expect(5); | ||
var Paginate = CanMap.extend({ | ||
@@ -429,7 +429,7 @@ define: { | ||
equal(p.attr("page"), 3, "page get right"); | ||
assert.equal(p.attr("page"), 3, "page get right"); | ||
p.bind("page", function(ev, newValue, oldValue) { | ||
equal(newValue, 2, "got new value event"); | ||
equal(oldValue, 3, "got old value event"); | ||
assert.equal(newValue, 2, "got new value event"); | ||
assert.equal(oldValue, 3, "got old value event"); | ||
}); | ||
@@ -439,5 +439,5 @@ | ||
equal(p.attr("page"), 2, "page set right"); | ||
assert.equal(p.attr("page"), 2, "page set right"); | ||
equal(p.attr("offset"), 10, "page offset set"); | ||
assert.equal(p.attr("offset"), 10, "page offset set"); | ||
@@ -447,3 +447,3 @@ | ||
QUnit.test("getter with initial value", function() { | ||
QUnit.test("getter with initial value", function(assert) { | ||
@@ -471,3 +471,3 @@ var comp = compute(1); | ||
// that there were no errors. | ||
equal(g.attr("vals").length, 0, "zero items in array"); | ||
assert.equal(g.attr("vals").length, 0, "zero items in array"); | ||
@@ -477,3 +477,3 @@ }); | ||
QUnit.test("serialize basics", function() { | ||
QUnit.test("serialize basics", function(assert) { | ||
var MyMap = CanMap.extend({ | ||
@@ -525,17 +525,17 @@ define: { | ||
}]); | ||
equal(map.attr("locationIds").length, 2, "get locationIds"); | ||
equal(map.attr("locationIds")[0], 1, "get locationIds index 0"); | ||
equal(map.attr("locations")[0].id, 1, "get locations index 0"); | ||
assert.equal(map.attr("locationIds").length, 2, "get locationIds"); | ||
assert.equal(map.attr("locationIds")[0], 1, "get locationIds index 0"); | ||
assert.equal(map.attr("locations")[0].id, 1, "get locations index 0"); | ||
var serialized = map.serialize(); | ||
equal(serialized.locations, undefined, "locations doesn't serialize"); | ||
equal(serialized.locationIds, "1,2", "locationIds serializes"); | ||
equal(serialized.name, undefined, "name doesn't serialize"); | ||
assert.equal(serialized.locations, undefined, "locations doesn't serialize"); | ||
assert.equal(serialized.locationIds, "1,2", "locationIds serializes"); | ||
assert.equal(serialized.name, undefined, "name doesn't serialize"); | ||
equal(serialized.bared, "foo+bar", "true adds computed props"); | ||
equal(serialized.ignored, undefined, "computed props are not serialized by default"); | ||
assert.equal(serialized.bared, "foo+bar", "true adds computed props"); | ||
assert.equal(serialized.ignored, undefined, "computed props are not serialized by default"); | ||
}); | ||
QUnit.test("serialize context", function() { | ||
QUnit.test("serialize context", function(assert) { | ||
var context, serializeContext; | ||
@@ -560,7 +560,7 @@ var MyMap = CanMap.extend({ | ||
map.serialize(); | ||
equal(context, map); | ||
equal(serializeContext, map); | ||
assert.equal(context, map); | ||
assert.equal(serializeContext, map); | ||
}); | ||
QUnit.test("methods contexts", function() { | ||
QUnit.test("methods contexts", function(assert) { | ||
var contexts = {}; | ||
@@ -605,10 +605,10 @@ var MyMap = CanMap.extend({ | ||
equal(contexts.get, map); | ||
equal(contexts.remove, map); | ||
equal(contexts.set, map); | ||
equal(contexts.serialize, map); | ||
equal(contexts.type, map); | ||
assert.equal(contexts.get, map); | ||
assert.equal(contexts.remove, map); | ||
assert.equal(contexts.set, map); | ||
assert.equal(contexts.serialize, map); | ||
assert.equal(contexts.type, map); | ||
}); | ||
QUnit.test("value generator is not called if default passed", function() { | ||
QUnit.test("value generator is not called if default passed", function(assert) { | ||
var TestMap = CanMap.extend({ | ||
@@ -628,6 +628,6 @@ define: { | ||
equal(tm.attr('foo'), 'baz'); | ||
assert.equal(tm.attr('foo'), 'baz'); | ||
}); | ||
QUnit.test("Value generator can read other properties", function() { | ||
QUnit.test("Value generator can read other properties", function(assert) { | ||
var Map = CanMap.extend({ | ||
@@ -695,20 +695,20 @@ letters: 'ABC', | ||
equal(map.attr('firstLetter'), 'A', | ||
assert.equal(map.attr('firstLetter'), 'A', | ||
prefix + 'traditional CanMap style property definition'); | ||
equal(map.attr('firstNumber'), 1, | ||
assert.equal(map.attr('firstNumber'), 1, | ||
prefix + 'traditional CanMap style property definition'); | ||
equal(map.attr('middleLetter'), 'E', | ||
assert.equal(map.attr('middleLetter'), 'E', | ||
prefix + 'define plugin style default property definition'); | ||
equal(map.attr('middleNumber'), 5, | ||
assert.equal(map.attr('middleNumber'), 5, | ||
prefix + 'define plugin style default property definition'); | ||
equal(map.attr('lastLetter'), 'I', | ||
assert.equal(map.attr('lastLetter'), 'I', | ||
prefix + 'define plugin style generated default property definition'); | ||
equal(map.attr('lastNumber'), 9, | ||
assert.equal(map.attr('lastNumber'), 9, | ||
prefix + 'define plugin style generated default property definition'); | ||
}); | ||
QUnit.test('default behaviors with "*" work for attributes', function() { | ||
expect(9); | ||
QUnit.test('default behaviors with "*" work for attributes', function(assert) { | ||
assert.expect(9); | ||
var DefaultMap = CanMap.extend({ | ||
@@ -725,7 +725,7 @@ define: { | ||
set: function(newVal) { | ||
ok(true, 'set called'); | ||
assert.ok(true, 'set called'); | ||
return newVal; | ||
}, | ||
remove: function(currentVal) { | ||
ok(true, 'remove called'); | ||
assert.ok(true, 'remove called'); | ||
return false; | ||
@@ -740,16 +740,16 @@ } | ||
equal(map.attr('someNumber'), 5, 'value of someNumber should be converted to a number'); | ||
assert.equal(map.attr('someNumber'), 5, 'value of someNumber should be converted to a number'); | ||
map.attr('number', '10'); // Custom set should be called | ||
equal(map.attr('number'), 10, 'value of number should be converted to a number'); | ||
assert.equal(map.attr('number'), 10, 'value of number should be converted to a number'); | ||
map.removeAttr('number'); // Custom removed should be called | ||
equal(map.attr('number'), 10, 'number should not be removed'); | ||
assert.equal(map.attr('number'), 10, 'number should not be removed'); | ||
serializedMap = map.serialize(); | ||
equal(serializedMap.number, '10', 'number serialized as string'); | ||
equal(serializedMap.someNumber, '5', 'someNumber serialized as string'); | ||
equal(serializedMap['*'], undefined, '"*" is not a value in serialized object'); | ||
assert.equal(serializedMap.number, '10', 'number serialized as string'); | ||
assert.equal(serializedMap.someNumber, '5', 'someNumber serialized as string'); | ||
assert.equal(serializedMap['*'], undefined, '"*" is not a value in serialized object'); | ||
}); | ||
QUnit.test('models properly serialize with default behaviors', function() { | ||
QUnit.test('models properly serialize with default behaviors', function(assert) { | ||
var DefaultMap = CanMap.extend({ | ||
@@ -775,8 +775,8 @@ define: { | ||
equal(serializedMap.age, undefined, 'age doesn\'t exist'); | ||
equal(serializedMap.name, undefined, 'name doesn\'t exist'); | ||
equal(serializedMap.shirt, 'blue', 'shirt exists'); | ||
assert.equal(serializedMap.age, undefined, 'age doesn\'t exist'); | ||
assert.equal(serializedMap.name, undefined, 'name doesn\'t exist'); | ||
assert.equal(serializedMap.shirt, 'blue', 'shirt exists'); | ||
}); | ||
QUnit.test("nested define", function() { | ||
QUnit.test("nested define", function(assert) { | ||
var nailedIt = 'Nailed it'; | ||
@@ -823,13 +823,15 @@ var Example = CanMap.extend({}, { | ||
// values are correct | ||
equal(nested.attr('test.name'), nailedIt); | ||
equal(nested.attr('examples.one.name'), nailedIt); | ||
equal(nested.attr('examples.two.deep.name'), nailedIt); | ||
assert.equal(nested.attr('test.name'), nailedIt); | ||
assert.equal(nested.attr('examples.one.name'), nailedIt); | ||
assert.equal(nested.attr('examples.two.deep.name'), nailedIt); | ||
// objects are correctly instanced | ||
ok(nested.attr('test') instanceof Example); | ||
ok(nested.attr('examples.one') instanceof Example); | ||
ok(nested.attr('examples.two.deep') instanceof Example); | ||
assert.ok(nested.attr('test') instanceof Example); | ||
assert.ok(nested.attr('examples.one') instanceof Example); | ||
assert.ok(nested.attr('examples.two.deep') instanceof Example); | ||
}); | ||
QUnit.test('Can make an attr alias a compute (#1470)', 9, function() { | ||
QUnit.test('Can make an attr alias a compute (#1470)', function(assert) { | ||
assert.expect(9); | ||
var computeValue = compute(1); | ||
@@ -860,3 +862,3 @@ var GetMap = CanMap.extend({ | ||
equal(getMap.attr("value"), 1); | ||
assert.equal(getMap.attr("value"), 1); | ||
@@ -869,12 +871,12 @@ var bindCallbacks = 0; | ||
case 0: | ||
equal(newVal, 2, "0 - bind called with new val"); | ||
equal(oldVal, 1, "0 - bind called with old val"); | ||
assert.equal(newVal, 2, "0 - bind called with new val"); | ||
assert.equal(oldVal, 1, "0 - bind called with old val"); | ||
break; | ||
case 1: | ||
equal(newVal, 3, "1 - bind called with new val"); | ||
equal(oldVal, 2, "1 - bind called with old val"); | ||
assert.equal(newVal, 3, "1 - bind called with new val"); | ||
assert.equal(oldVal, 2, "1 - bind called with old val"); | ||
break; | ||
case 2: | ||
equal(newVal, 4, "2 - bind called with new val"); | ||
equal(oldVal, 3, "2 - bind called with old val"); | ||
assert.equal(newVal, 4, "2 - bind called with new val"); | ||
assert.equal(oldVal, 3, "2 - bind called with old val"); | ||
break; | ||
@@ -893,4 +895,4 @@ } | ||
equal(getMap.attr("value"), 3, "read value is 3"); | ||
equal(computeValue(), 3, "the compute value is 3"); | ||
assert.equal(getMap.attr("value"), 3, "read value is 3"); | ||
assert.equal(computeValue(), 3, "the compute value is 3"); | ||
@@ -904,3 +906,3 @@ // Try setting to a new comptue | ||
QUnit.test('setting a value of a property with type "compute" triggers change events', function() { | ||
QUnit.test('setting a value of a property with type "compute" triggers change events', function(assert) { | ||
@@ -916,5 +918,5 @@ var handler; | ||
}; | ||
equal(newVal, expectedNewVal, sub(message, subs)); | ||
assert.equal(newVal, expectedNewVal, sub(message, subs)); | ||
subs.prop = 'oldVal'; | ||
equal(oldVal, expectedOldVal, sub(message, subs)); | ||
assert.equal(oldVal, expectedOldVal, sub(message, subs)); | ||
}; | ||
@@ -937,3 +939,3 @@ }; | ||
equal(m1.attr('computed'), 0, 'm1 is 1'); | ||
assert.equal(m1.attr('computed'), 0, 'm1 is 1'); | ||
@@ -951,3 +953,3 @@ handler = createChangeHandler(0, 1, ".attr('computed', newVal)"); | ||
QUnit.test('replacing the compute on a property with type "compute"', function() { | ||
QUnit.test('replacing the compute on a property with type "compute"', function(assert) { | ||
var compute1 = compute(0); | ||
@@ -969,3 +971,3 @@ var compute2 = compute(1); | ||
equal(m.attr('computable'), 0, 'compute1 readable via .attr()'); | ||
assert.equal(m.attr('computable'), 0, 'compute1 readable via .attr()'); | ||
@@ -975,3 +977,3 @@ m.attr('computable', compute2); | ||
equal(m.attr('computable'), 1, 'compute2 readable via .attr()'); | ||
assert.equal(m.attr('computable'), 1, 'compute2 readable via .attr()'); | ||
}); | ||
@@ -981,3 +983,3 @@ | ||
// TODO remove this condition when taking the plugins out of the main repository | ||
QUnit.test('value and get (#1521)', function() { | ||
QUnit.test('value and get (#1521)', function(assert) { | ||
var MyMap = CanMap.extend({ | ||
@@ -1002,7 +1004,7 @@ define: { | ||
var map = new MyMap({}); | ||
equal(map.attr('size'), 2); | ||
assert.equal(map.attr('size'), 2); | ||
}); | ||
QUnit.test("One event on getters (#1585)", function() { | ||
QUnit.test("One event on getters (#1585)", function(assert) { | ||
@@ -1042,6 +1044,6 @@ var AppState = CanMap.extend({ | ||
equal(personEvents, 2); | ||
assert.equal(personEvents, 2); | ||
}); | ||
QUnit.test('Can read a defined property with a set/get method (#1648)', function() { | ||
QUnit.test('Can read a defined property with a set/get method (#1648)', function(assert) { | ||
// Problem: "get" is not passed the correct "lastSetVal" | ||
@@ -1066,10 +1068,12 @@ // Problem: Cannot read the value of "foo" | ||
equal(map.attr('foo'), '', 'Calling .attr(\'foo\') returned the correct value'); | ||
assert.equal(map.attr('foo'), '', 'Calling .attr(\'foo\') returned the correct value'); | ||
map.attr('foo', 'baz'); | ||
equal(map.attr('foo'), 'baz', 'Calling .attr(\'foo\') returned the correct value'); | ||
assert.equal(map.attr('foo'), 'baz', 'Calling .attr(\'foo\') returned the correct value'); | ||
}); | ||
QUnit.test('Can bind to a defined property with a set/get method (#1648)', 3, function() { | ||
QUnit.test('Can bind to a defined property with a set/get method (#1648)', function(assert) { | ||
assert.expect(3); | ||
// Problem: "get" is not called before and after the "set" | ||
@@ -1096,14 +1100,14 @@ // Problem: Function bound to "foo" is not called | ||
map.bind('foo', function() { | ||
ok(true, 'Bound function is called'); | ||
assert.ok(true, 'Bound function is called'); | ||
}); | ||
equal(map.attr('foo'), '', 'Calling .attr(\'foo\') returned the correct value'); | ||
assert.equal(map.attr('foo'), '', 'Calling .attr(\'foo\') returned the correct value'); | ||
map.attr('foo', 'baz'); | ||
equal(map.attr('foo'), 'baz', 'Calling .attr(\'foo\') returned the correct value'); | ||
assert.equal(map.attr('foo'), 'baz', 'Calling .attr(\'foo\') returned the correct value'); | ||
}); | ||
QUnit.test("type converters handle null and undefined in expected ways (1693)", function() { | ||
QUnit.test("type converters handle null and undefined in expected ways (1693)", function(assert) { | ||
@@ -1147,13 +1151,13 @@ var Typer = CanMap.extend({ | ||
equal(t.attr("date"), undefined, "converted to date"); | ||
assert.equal(t.attr("date"), undefined, "converted to date"); | ||
equal(t.attr("string"), undefined, "converted to string"); | ||
assert.equal(t.attr("string"), undefined, "converted to string"); | ||
equal(t.attr("number"), undefined, "converted to number"); | ||
assert.equal(t.attr("number"), undefined, "converted to number"); | ||
equal(t.attr("boolean"), undefined, "converted to boolean"); | ||
assert.equal(t.attr("boolean"), undefined, "converted to boolean"); | ||
equal(t.attr("htmlbool"), false, "converted to htmlbool"); | ||
assert.equal(t.attr("htmlbool"), false, "converted to htmlbool"); | ||
equal(t.attr("leaveAlone"), undefined, "left as object"); | ||
assert.equal(t.attr("leaveAlone"), undefined, "left as object"); | ||
@@ -1169,18 +1173,18 @@ t = new Typer().attr({ | ||
equal(t.attr("date"), null, "converted to date"); | ||
assert.equal(t.attr("date"), null, "converted to date"); | ||
equal(t.attr("string"), null, "converted to string"); | ||
assert.equal(t.attr("string"), null, "converted to string"); | ||
equal(t.attr("number"), null, "converted to number"); | ||
assert.equal(t.attr("number"), null, "converted to number"); | ||
equal(t.attr("boolean"), null, "converted to boolean"); | ||
assert.equal(t.attr("boolean"), null, "converted to boolean"); | ||
equal(t.attr("htmlbool"), false, "converted to htmlbool"); | ||
assert.equal(t.attr("htmlbool"), false, "converted to htmlbool"); | ||
equal(t.attr("leaveAlone"), null, "left as object"); | ||
assert.equal(t.attr("leaveAlone"), null, "left as object"); | ||
}); | ||
QUnit.test('Initial value does not call getter', function() { | ||
expect(0); | ||
QUnit.test('Initial value does not call getter', function(assert) { | ||
assert.expect(0); | ||
@@ -1191,3 +1195,3 @@ var Map = CanMap.extend({ | ||
get: function(lastVal) { | ||
ok(false, 'Should not be called'); | ||
assert.ok(false, 'Should not be called'); | ||
return lastVal; | ||
@@ -1204,3 +1208,3 @@ } | ||
QUnit.test("getters produce change events", function() { | ||
QUnit.test("getters produce change events", function(assert) { | ||
var Map = CanMap.extend({ | ||
@@ -1219,3 +1223,3 @@ define: { | ||
map.bind("change", function() { | ||
ok(true, "change called"); | ||
assert.ok(true, "change called"); | ||
}); | ||
@@ -1226,5 +1230,5 @@ | ||
QUnit.test("Asynchronous virtual properties cause extra recomputes (#1915)", function() { | ||
QUnit.test("Asynchronous virtual properties cause extra recomputes (#1915)", function(assert) { | ||
stop(); | ||
var done = assert.async(); | ||
@@ -1248,3 +1252,3 @@ var ran = false; | ||
if (ran) { | ||
ok(false, 'Getter ran twice'); | ||
assert.ok(false, 'Getter ran twice'); | ||
} | ||
@@ -1263,4 +1267,4 @@ ran = true; | ||
setTimeout(function() { | ||
equal(vm.attr('bar'), 10); | ||
start(); | ||
assert.equal(vm.attr('bar'), 10); | ||
done(); | ||
}, 200); | ||
@@ -1271,3 +1275,3 @@ | ||
QUnit.test("double get in a compute (#2230)", function() { | ||
QUnit.test("double get in a compute (#2230)", function(assert) { | ||
var VM = CanMap.extend({ | ||
@@ -1277,3 +1281,3 @@ define: { | ||
get: function(val, setVal) { | ||
ok(setVal, "setVal passed"); | ||
assert.ok(setVal, "setVal passed"); | ||
return 'Hi!'; | ||
@@ -1329,3 +1333,3 @@ } | ||
QUnit.test("Wildcard serialize doesn't apply to getter properties (#4)", function() { | ||
QUnit.test("Wildcard serialize doesn't apply to getter properties (#4)", function(assert) { | ||
var VM = CanMap.extend({ | ||
@@ -1353,3 +1357,3 @@ define: { | ||
deepEqual(vm.serialize(), { | ||
assert.deepEqual(vm.serialize(), { | ||
explicitlySerialized: true, | ||
@@ -1371,3 +1375,5 @@ implicitlySerialized: true | ||
QUnit.test("can inherit computes from another map (#2)", 4, function(){ | ||
QUnit.test("can inherit computes from another map (#2)", function(assert) { | ||
assert.expect(4); | ||
var string1 = 'a string'; | ||
@@ -1388,3 +1394,3 @@ var string2 = 'another string'; | ||
set: function(newVal) { | ||
equal(newVal, string1, 'set was called'); | ||
assert.equal(newVal, string1, 'set was called'); | ||
} | ||
@@ -1411,5 +1417,5 @@ } | ||
equal(map.attr('propC'), string2, 'props only in the child have the correct values'); | ||
equal(map.attr('propB'), string2, 'props in both have the child values'); | ||
equal(map.attr('propA'), string1, 'props only in the parent have the correct values'); | ||
assert.equal(map.attr('propC'), string2, 'props only in the child have the correct values'); | ||
assert.equal(map.attr('propB'), string2, 'props in both have the child values'); | ||
assert.equal(map.attr('propA'), string1, 'props only in the parent have the correct values'); | ||
map.attr('propB', string1); | ||
@@ -1419,3 +1425,3 @@ | ||
QUnit.test("can inherit primitive values from another map (#2)", function(){ | ||
QUnit.test("can inherit primitive values from another map (#2)", function(assert) { | ||
var string1 = 'a'; | ||
@@ -1447,9 +1453,9 @@ var string2 = 'b'; | ||
equal(map.propC, string2, 'props only in the child have the correct values'); | ||
equal(map.propB, string2, 'props in both have the child values'); | ||
equal(map.propA, string1, 'props only in the parent have the correct values'); | ||
assert.equal(map.propC, string2, 'props only in the child have the correct values'); | ||
assert.equal(map.propB, string2, 'props in both have the child values'); | ||
assert.equal(map.propA, string1, 'props only in the parent have the correct values'); | ||
}); | ||
QUnit.test("can inherit object values from another map (#2)", function(){ | ||
QUnit.test("can inherit object values from another map (#2)", function(assert) { | ||
var object1 = {a: 'a'}; | ||
@@ -1489,9 +1495,9 @@ var object2 = {b: 'b'}; | ||
equal(map.attr('propC'), object2, 'props only in the child have the correct values'); | ||
equal(map.attr('propB'), object2, 'props in both have the child values'); | ||
equal(map.attr('propA'), object1, 'props only in the parent have the correct values'); | ||
assert.equal(map.attr('propC'), object2, 'props only in the child have the correct values'); | ||
assert.equal(map.attr('propB'), object2, 'props in both have the child values'); | ||
assert.equal(map.attr('propA'), object1, 'props only in the parent have the correct values'); | ||
}); | ||
QUnit.test("can set properties to undefined", function(){ | ||
QUnit.test("can set properties to undefined", function(assert) { | ||
var MyMap = CanMap.extend({ | ||
@@ -1510,6 +1516,6 @@ define: { | ||
map.attr('foo', 'bar'); | ||
equal(map.attr('foo'), 'bar', 'foo should be bar'); | ||
assert.equal(map.attr('foo'), 'bar', 'foo should be bar'); | ||
map.attr('foo', undefined); | ||
equal(typeof map.attr('foo'), 'undefined', 'foo should be undefined'); | ||
assert.equal(typeof map.attr('foo'), 'undefined', 'foo should be undefined'); | ||
}); | ||
@@ -1564,3 +1570,3 @@ | ||
QUnit.test("value function not set on constructor defaults", function(){ | ||
QUnit.test("value function not set on constructor defaults", function(assert) { | ||
var MyMap = CanMap.extend({ | ||
@@ -1578,9 +1584,9 @@ define: { | ||
equal(MyMap.defaults.propA, undefined, 'Generator function does not result in property set on defaults'); | ||
notEqual(MyMap.defaultGenerators.propA, undefined, 'Generator function set on defaultGenerators'); | ||
equal(map.attr("propA"), 1, 'Instance value set properly'); //this is mainly so that CI doesn't complain about unused variable | ||
assert.equal(MyMap.defaults.propA, undefined, 'Generator function does not result in property set on defaults'); | ||
assert.notEqual(MyMap.defaultGenerators.propA, undefined, 'Generator function set on defaultGenerators'); | ||
assert.equal(map.attr("propA"), 1, 'Instance value set properly'); //this is mainly so that CI doesn't complain about unused variable | ||
}); | ||
QUnit.test("can.hasKey", function() { | ||
QUnit.test("can.hasKey", function(assert) { | ||
var Parent = CanMap.extend({ | ||
@@ -1629,18 +1635,18 @@ define: { | ||
// hasKey | ||
equal(canReflect.hasKey(vm, "prop"), true, "vm.hasKey('prop') true"); | ||
equal(canReflect.hasKey(vm, "derivedProp"), true, "vm.hasKey('derivedProp') true"); | ||
assert.equal(canReflect.hasKey(vm, "prop"), true, "vm.hasKey('prop') true"); | ||
assert.equal(canReflect.hasKey(vm, "derivedProp"), true, "vm.hasKey('derivedProp') true"); | ||
equal(canReflect.hasKey(vm, "parentProp"), true, "vm.hasKey('parentProp') true"); | ||
equal(canReflect.hasKey(vm, "parentDerivedProp"), true, "vm.hasKey('parentDerivedProp') true"); | ||
assert.equal(canReflect.hasKey(vm, "parentProp"), true, "vm.hasKey('parentProp') true"); | ||
assert.equal(canReflect.hasKey(vm, "parentDerivedProp"), true, "vm.hasKey('parentDerivedProp') true"); | ||
equal(canReflect.hasKey(vm, "anotherProp"), false, "vm.hasKey('anotherProp') false"); | ||
assert.equal(canReflect.hasKey(vm, "anotherProp"), false, "vm.hasKey('anotherProp') false"); | ||
equal(canReflect.hasKey(vm, "aFunction"), true, "vm.hasKey('aFunction') true"); | ||
equal(canReflect.hasKey(vm, "parentFunction"), true, "vm.hasKey('parentFunction') true"); | ||
assert.equal(canReflect.hasKey(vm, "aFunction"), true, "vm.hasKey('aFunction') true"); | ||
assert.equal(canReflect.hasKey(vm, "parentFunction"), true, "vm.hasKey('parentFunction') true"); | ||
vm.attr('lateProp', 'something'); | ||
equal(canReflect.hasKey(vm, "lateProp"), true, "vm.hasKey('lateProp') true"); | ||
assert.equal(canReflect.hasKey(vm, "lateProp"), true, "vm.hasKey('lateProp') true"); | ||
}); | ||
QUnit.test("can.getOwnEnumerableKeys", function() { | ||
QUnit.test("can.getOwnEnumerableKeys", function(assert) { | ||
var ParentMap = CanMap.extend({ | ||
@@ -1696,17 +1702,17 @@ define: { | ||
// getOwnEnumerableKeys for defined props, including copied from Parent | ||
deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "enumerableProp", "enumByDefault", "parentEnum", "parentEnumByDefault" ], "vm.getOwnEnumerableKeys()"); | ||
assert.deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "enumerableProp", "enumByDefault", "parentEnum", "parentEnumByDefault" ], "vm.getOwnEnumerableKeys()"); | ||
vm.attr('lateProp', true); | ||
deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "enumerableProp", "enumByDefault", "parentEnum", "parentEnumByDefault", "lateProp" ], "vm.getOwnEnumerableKeys() with late prop"); | ||
assert.deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "enumerableProp", "enumByDefault", "parentEnum", "parentEnumByDefault", "lateProp" ], "vm.getOwnEnumerableKeys() with late prop"); | ||
}); | ||
QUnit.test("can.getOwnEnumerableKeys works without define (#81)", function() { | ||
QUnit.test("can.getOwnEnumerableKeys works without define (#81)", function(assert) { | ||
var VM = CanMap.extend({}); | ||
var vm = new VM({ foo: "bar" }); | ||
deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo" ], "without define"); | ||
assert.deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo" ], "without define"); | ||
vm.attr("abc", "xyz"); | ||
deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo", "abc" ], "without define, with late prop"); | ||
assert.deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo", "abc" ], "without define, with late prop"); | ||
@@ -1718,13 +1724,13 @@ VM = CanMap.extend({ | ||
vm = new VM({ foo: "bar" }); | ||
deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo" ], "with empty define"); | ||
assert.deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo" ], "with empty define"); | ||
vm.attr("abc", "xyz"); | ||
deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo", "abc" ], "with empty define, with late prop"); | ||
assert.deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo", "abc" ], "with empty define, with late prop"); | ||
}); | ||
QUnit.test("can.getOwnEnumerableKeys works with null", function() { | ||
QUnit.test("can.getOwnEnumerableKeys works with null", function(assert) { | ||
var VM = CanMap.extend({}); | ||
var vm = new VM({ foo: null }); | ||
deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo" ], "getOwnEnumerableKeys works with null"); | ||
assert.deepEqual( canReflect.getOwnEnumerableKeys(vm), [ "foo" ], "getOwnEnumerableKeys works with null"); | ||
}); | ||
@@ -1731,0 +1737,0 @@ |
{ | ||
"name": "can-map-define", | ||
"version": "4.3.7", | ||
"version": "4.3.8", | ||
"description": "Define rich attribute behavior", | ||
@@ -53,3 +53,3 @@ "homepage": "https://canjs.com", | ||
"can-key": "<2.0.0", | ||
"can-reflect-tests": "^0.2.1", | ||
"can-reflect-tests": "^0.3.1", | ||
"can-route": "^4.1.1", | ||
@@ -61,3 +61,3 @@ "can-stache": "^4.1.3", | ||
"steal": "^1.2.9", | ||
"steal-qunit": "^1.0.1", | ||
"steal-qunit": "^2.0.0", | ||
"steal-tools": "^1.1.2", | ||
@@ -64,0 +64,0 @@ "testee": "^0.9.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
89179
1921