1.1 --- a/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java Thu May 16 13:40:26 2013 +0200
1.2 +++ b/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java Tue May 28 20:01:30 2013 +0200
1.3 @@ -24,6 +24,7 @@
1.4 import net.java.html.json.ComputedProperty;
1.5 import net.java.html.json.Function;
1.6 import net.java.html.json.Model;
1.7 +import net.java.html.json.Models;
1.8 import net.java.html.json.Property;
1.9 import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
1.10 import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
1.11 @@ -48,7 +49,7 @@
1.12 "<button id=\"hello\">Say Hello!</button>\n"
1.13 )
1.14 @BrwsrTest public void modifyValueAssertChangeInModel() throws Exception {
1.15 - KnockoutModel m = new KnockoutModel(Utils.newContext());
1.16 + KnockoutModel m = Models.bind(new KnockoutModel(), Utils.newContext());
1.17 m.setName("Kukuc");
1.18 m.applyBindings();
1.19
1.20 @@ -82,7 +83,7 @@
1.21 + "</ul>\n"
1.22 )
1.23 @BrwsrTest public void displayContentOfArray() throws Exception {
1.24 - KnockoutModel m = new KnockoutModel(Utils.newContext());
1.25 + KnockoutModel m = Models.bind(new KnockoutModel(), Utils.newContext());
1.26 m.getResults().add("Ahoj");
1.27 m.applyBindings();
1.28
1.29 @@ -104,7 +105,7 @@
1.30 "<input type='checkbox' id='b' data-bind='checked: enabled'></input>\n"
1.31 )
1.32 @BrwsrTest public void checkBoxToBooleanBinding() throws Exception {
1.33 - KnockoutModel m = new KnockoutModel(Utils.newContext());
1.34 + KnockoutModel m = Models.bind(new KnockoutModel(), Utils.newContext());
1.35 m.applyBindings();
1.36
1.37 assert !m.isEnabled() : "Is disabled";
1.38 @@ -122,7 +123,7 @@
1.39 + "</ul>\n"
1.40 )
1.41 @BrwsrTest public void displayContentOfDerivedArray() throws Exception {
1.42 - KnockoutModel m = new KnockoutModel(Utils.newContext());
1.43 + KnockoutModel m = Models.bind(new KnockoutModel(), Utils.newContext());
1.44 m.getResults().add("Ahoj");
1.45 m.applyBindings();
1.46
1.47 @@ -141,9 +142,9 @@
1.48 + "</ul>\n"
1.49 )
1.50 @BrwsrTest public void displayContentOfArrayOfPeople() throws Exception {
1.51 - KnockoutModel m = new KnockoutModel(Utils.newContext());
1.52 + KnockoutModel m = Models.bind(new KnockoutModel(), Utils.newContext());
1.53
1.54 - final Person first = new Person(Utils.newContext());
1.55 + final Person first = Models.bind(new Person(), Utils.newContext());
1.56 first.setFirstName("first");
1.57 m.getPeople().add(first);
1.58
1.59 @@ -152,7 +153,7 @@
1.60 int cnt = countChildren("ul");
1.61 assert cnt == 1 : "One child, but was " + cnt;
1.62
1.63 - final Person second = new Person(Utils.newContext());
1.64 + final Person second = Models.bind(new Person(), Utils.newContext());
1.65 second.setFirstName("second");
1.66 m.getPeople().add(second);
1.67
1.68 @@ -199,9 +200,9 @@
1.69 }
1.70
1.71 private void trasfertToFemale() throws Exception {
1.72 - KnockoutModel m = new KnockoutModel(Utils.newContext());
1.73 + KnockoutModel m = Models.bind(new KnockoutModel(), Utils.newContext());
1.74
1.75 - final Person first = new Person(Utils.newContext());
1.76 + final Person first = Models.bind(new Person(), Utils.newContext());
1.77 first.setFirstName("first");
1.78 first.setSex(Sex.MALE);
1.79 m.getPeople().add(first);