Skip to content

Commit

Permalink
add test for canjs#626
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxrev committed Dec 21, 2013
1 parent 187db18 commit ca3affb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions map/map_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,28 @@ test("can.each used with maps", function(){
})


test("can.Map serialize triggers reading (#626)", function(){
var old = can.__reading;

var attributesRead = [];
var readingTriggeredForKeys = false;

can.__reading = function(object, attribute) {
if (attribute === "__keys"){
readingTriggeredForKeys = true;
} else {
attributesRead.push(attribute);
}
}

var testMap = new can.Map({ cats: "meow", dogs: "bark" });

testMap.serialize();

ok(attributesRead[0] === "cats" && attributesRead[1] === "dogs", "map serialization triggered __reading on all attributes");
ok(readingTriggeredForKeys, "map serialization triggered __reading for __keys");

can.__reading = old;
})

})();

0 comments on commit ca3affb

Please sign in to comment.