Skip to content

Commit

Permalink
Merge pull request knockout#664 from SteveSanderson/664-further-spec-…
Browse files Browse the repository at this point in the history
…fixes

Further 2.2.0rc spec failures
  • Loading branch information
rniemeyer committed Oct 9, 2012
2 parents 2dc327b + 46cadd1 commit c96b99e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
10 changes: 8 additions & 2 deletions spec/defaultBindings/attrBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ describe('Binding: Attr', {
testNode.innerHTML = "<input data-bind='attr: { name: myValue }' />";
ko.applyBindings({ myValue: myValue }, testNode);
value_of(testNode.childNodes[0].name).should_be("myName");
value_of(testNode.childNodes[0].outerHTML).should_match('name="?myName"?');
if (testNode.childNodes[0].outerHTML) { // Old Firefox doesn't support outerHTML
value_of(testNode.childNodes[0].outerHTML).should_match('name="?myName"?');
}
value_of(testNode.childNodes[0].getAttribute("name")).should_be("myName");

// Also check we can remove it (which, for a name attribute, means setting it to an empty string)
myValue(false);
value_of(testNode.childNodes[0].name).should_be("");
value_of(testNode.childNodes[0].outerHTML).should_not_match('name="?([^">]+)');
if (testNode.childNodes[0].outerHTML) { // Old Firefox doesn't support outerHTML
value_of(testNode.childNodes[0].outerHTML).should_not_match('name="?([^">]+)');
}
value_of(testNode.childNodes[0].getAttribute("name")).should_be("");
},

'Should respond to changes in an observable value': function() {
Expand Down
2 changes: 1 addition & 1 deletion spec/domNodeDisposalBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('DOM node disposal', {
ko.utils.domNodeDisposal.addDisposeCallback(originalNode, function() { });

// Clone it, then dispose it. Then check it's still safe to associate DOM data with the clone.
var cloneNode = originalNode.cloneNode();
var cloneNode = originalNode.cloneNode(true);
ko.cleanNode(originalNode);
ko.utils.domNodeDisposal.addDisposeCallback(cloneNode, function() { });
}
Expand Down
17 changes: 9 additions & 8 deletions spec/editDetectionBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ describe('Compare Arrays', {
var oldArray = ["A", "B", "C", "D", "E"];
var newArray = ["F", "G", "H", "I", "J"];
var compareResult = ko.utils.compareArrays(oldArray, newArray);
// the order of added and deleted doesn't really matter
compareResult.sort(function(a, b) { return a.status.localeCompare(b.status) });
// The order of added and deleted doesn't really matter. We sort by a property that
// contains unique values to ensure the results are in a known order for verification.
compareResult.sort(function(a, b) { return a.value.localeCompare(b.value) });
value_of(compareResult).should_be([
{ status: "added", value: "F", index: 0},
{ status: "added", value: "G", index: 1},
{ status: "added", value: "H", index: 2},
{ status: "added", value: "I", index: 3},
{ status: "added", value: "J", index: 4},
{ status: "deleted", value: "A", index: 0},
{ status: "deleted", value: "B", index: 1},
{ status: "deleted", value: "C", index: 2},
{ status: "deleted", value: "D", index: 3},
{ status: "deleted", value: "E", index: 4}
{ status: "deleted", value: "E", index: 4},
{ status: "added", value: "F", index: 0},
{ status: "added", value: "G", index: 1},
{ status: "added", value: "H", index: 2},
{ status: "added", value: "I", index: 3},
{ status: "added", value: "J", index: 4}
]);
}
});
Expand Down
5 changes: 4 additions & 1 deletion spec/mappingHelperBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ describe('Mapping helpers', {
value_of(ko.toJSON(data, myReplacer)).should_be("\"my replacement\"");

// With spacer
value_of(ko.toJSON(data, undefined, " ")).should_be("{\n \"a\": 1\n}");
value_of(ko.toJSON(data, undefined, " ")).should_be_one_of([
"{\n \"a\":1\n}", // Firefox 3.6, for some reason, omits the space after the colon. Doesn't really matter to us.
"{\n \"a\": 1\n}" // All other browsers produce this format
]);
}
})

0 comments on commit c96b99e

Please sign in to comment.