1.1 --- a/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java Tue Aug 26 17:31:21 2014 +0200
1.2 +++ b/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java Tue Aug 26 17:31:51 2014 +0200
1.3 @@ -634,6 +634,38 @@
1.4 Utils.exposeHTML(KnockoutTest.class, "");
1.5 }
1.6 }
1.7 +
1.8 + @KOTest public void archetypeArrayModificationVisible() throws Exception {
1.9 + Object exp = Utils.exposeHTML(KnockoutTest.class,
1.10 + "<div>\n"
1.11 + + "<ul id='ul' data-bind='foreach: archetypes'>\n"
1.12 + + " <li data-bind='text: artifactId'></li>\n"
1.13 + + "</ul>\n"
1.14 + + "</div>\n"
1.15 + );
1.16 + try {
1.17 + KnockoutModel m = Models.bind(new KnockoutModel(), newContext());
1.18 + m.applyBindings();
1.19 +
1.20 + int cnt = Utils.countChildren(KnockoutTest.class, "ul");
1.21 + assert cnt == 0 : "No children " + cnt;
1.22 +
1.23 + Object arr = Utils.addChildren(KnockoutTest.class, "ul", "archetypes", new ArchetypeData("aid", "gid", "v", "n", "d", "u"));
1.24 + assert arr instanceof Object[] : "Got back an array: " + arr;
1.25 + final int len = ((Object[])arr).length;
1.26 +
1.27 + assert len == 1 : "One element in the array " + len;
1.28 +
1.29 + int newCnt = Utils.countChildren(KnockoutTest.class, "ul");
1.30 + assert newCnt == 1 : "One child in the DOM: " + newCnt;
1.31 +
1.32 + assert m.getArchetypes().size() == 1 : "One archetype: " + m.getArchetypes();
1.33 + assert m.getArchetypes().get(0) != null : "Not null: " + m.getArchetypes();
1.34 + assert m.getArchetypes().get(0).getArtifactId().equals("aid") : "'aid' == " + m.getArchetypes();
1.35 + } finally {
1.36 + Utils.exposeHTML(KnockoutTest.class, "");
1.37 + }
1.38 + }
1.39
1.40 @Function
1.41 static void call(KnockoutModel m, String data) {