Skip to content

Commit

Permalink
Added tests for Issue #137
Browse files Browse the repository at this point in the history
  • Loading branch information
Tavriets committed Feb 16, 2013
1 parent 3f7a34c commit 6d8c168
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/mappingBehaviors.js
Expand Up @@ -1778,6 +1778,34 @@ test('ko.mapping.fromJS should copy specified single property, also when going b
equal(js.b, undefined);
});

test('ko.mapping.fromJS with observe option should not fail when map data with sub-object', function() {
var data = {
a: "a",
b: {
c: "c"
}
};

var result = ko.mapping.fromJS(data, { observe: "a" });
equal(ko.isObservable(result.a), true);
equal(ko.isObservable(result.b), false);
equal(ko.isObservable(result.b.c), false);
});

test('ko.mapping.fromJS should observe property in sub-object', function() {
var data = {
a: "a",
b: {
c: "c"
}
};

var result = ko.mapping.fromJS(data, { observe: "b.c" });
equal(ko.isObservable(result.a), false);
equal(ko.isObservable(result.b), false);
equal(ko.isObservable(result.b.c), true);
});

test('ko.mapping.fromJS explicit declared none observable members should not be mapped to an observable', function() {
var data = {
a: "a",
Expand Down

0 comments on commit 6d8c168

Please sign in to comment.