Skip to content

Commit

Permalink
fixes a bug with toJSON method in an attr_list
Browse files Browse the repository at this point in the history
  • Loading branch information
semmypurewal committed Oct 28, 2012
1 parent 99d8fd0 commit b717a2e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
20 changes: 20 additions & 0 deletions spec/core/attr_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,26 @@ describe("AttrList", function () {
});
});

describe("toJSON method", function () {
it("should return a JSON representation of the elements in the list", function () {
var testObj = ["john", "semmy", "mark", "jim"];

obj.friends().add("john");
obj.friends().add("semmy");
obj.friends().add("mark");
obj.friends().add("jim");
expect(obj.friends()).toBeDefined();

expect(function () {
obj.friends().toJSON();
}).not.toThrow();

expect(obj.friends().toJSON()).toEqual(testObj);


});
});

describe("pop method", function () {
it("should return the object which was popped", function () {
var lastObj = "mark",
Expand Down
8 changes: 5 additions & 3 deletions src/core/attr_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ window.jermaine.util.namespace("window.jermaine", function (ns) {
i, j;

//check to make sure the current list is not in JSONreps
for (i = 0;i < JSONreps.length; ++i) {
if (JSONreps[i].object === this) {
result = JSONreps[i].JSONrep;
if (JSONreps !== undefined) {
for (i = 0;i < JSONreps.length; ++i) {
if (JSONreps[i].object === this) {
result = JSONreps[i].JSONrep;
}
}
}

Expand Down

0 comments on commit b717a2e

Please sign in to comment.