You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by da...@apache.org on 2017/08/24 08:25:09 UTC

[03/13] incubator-weex git commit: + [test] add test case for using append tree in child components

+ [test] add test case for using append tree in child components


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/296ac477
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/296ac477
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/296ac477

Branch: refs/heads/0.16-dev
Commit: 296ac477922814c800ad42aa208ed895e1b12d4b
Parents: faca556
Author: Hanks <zh...@gmail.com>
Authored: Wed Aug 23 15:33:15 2017 +0800
Committer: Hanks <zh...@gmail.com>
Committed: Wed Aug 23 15:33:15 2017 +0800

----------------------------------------------------------------------
 .../complex/component-append-tree.output.js     | 22 +++++++
 .../complex/component-append-tree.source.js     | 68 ++++++++++++++++++++
 html5/test/case/tester.js                       | 19 ++++++
 3 files changed, 109 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/296ac477/html5/test/case/complex/component-append-tree.output.js
----------------------------------------------------------------------
diff --git a/html5/test/case/complex/component-append-tree.output.js b/html5/test/case/complex/component-append-tree.output.js
new file mode 100644
index 0000000..6c036ec
--- /dev/null
+++ b/html5/test/case/complex/component-append-tree.output.js
@@ -0,0 +1,22 @@
+{
+  type: 'scroller',
+  children: [{
+    type: 'div',
+    attr: { "append": "node" },
+    children: [{
+      type: 'text',
+      attr: {
+        value: 'ready'
+      }
+    }]
+  }, {
+    type: 'div',
+    attr: { "append": "tree" },
+    children: [{
+      type: 'text',
+      attr: {
+        value: 'ready'
+      }
+    }]
+  }]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/296ac477/html5/test/case/complex/component-append-tree.source.js
----------------------------------------------------------------------
diff --git a/html5/test/case/complex/component-append-tree.source.js b/html5/test/case/complex/component-append-tree.source.js
new file mode 100644
index 0000000..2f83adc
--- /dev/null
+++ b/html5/test/case/complex/component-append-tree.source.js
@@ -0,0 +1,68 @@
+define('@weex-component/sub', function(require, exports, module) {
+  
+      ;
+      module.exports = {
+          data: function() {
+              return {
+                  str: '-----'
+              }
+          },
+          ready: function() {
+              this.str = 'ready'
+              setTimeout(() => {
+                  this.str = 'timeout'
+              }, 100)
+          }
+      }
+  
+  
+      ;
+      module.exports.style = {}
+  
+      ;
+      module.exports.template = {
+          "type": "text",
+          "attr": {
+              "value": function() {
+                  return this.str
+              }
+          }
+      }
+  
+      ;
+  })
+  
+  // module
+  
+  define('@weex-component/ad164d40f42747f598b56eccfd0eae8e', function(require, exports, module) {
+  
+      ;
+  
+      ;
+      module.exports.style = {}
+  
+      ;
+      module.exports.template = {
+          "type": "scroller",
+          "children": [{
+              "type": "div",
+              "append": "node",
+              "children": [{
+                  "type": "sub"
+              }]
+          }, {
+              "type": "div",
+              "append": "tree",
+              "children": [{
+                  "type": "sub"
+              }]
+          }]
+      }
+  
+      ;
+  })
+  
+  // require module
+  bootstrap('@weex-component/ad164d40f42747f598b56eccfd0eae8e', {
+      "transformerVersion": "0.4.3"
+  })
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/296ac477/html5/test/case/tester.js
----------------------------------------------------------------------
diff --git a/html5/test/case/tester.js b/html5/test/case/tester.js
index 373a421..3a1caf4 100644
--- a/html5/test/case/tester.js
+++ b/html5/test/case/tester.js
@@ -196,6 +196,25 @@ describe('test input and output', function () {
       app.$destroy()
     })
 
+    it.skip('use append tree and sub components', (done) => {
+      const name = 'component-append-tree'
+      const sourceCode = readSource(name)
+      const outputCode = readOutput(name)
+
+      app.$create(sourceCode)
+      const expected = eval('(' + outputCode + ')')
+      const actual = app.getRealRoot()
+      expect(actual).eql(expected)
+
+      setTimeout(() => {
+        const actual2 = app.getRealRoot()
+        expect(actual2.children[0].children[0].attr.value).eql('timeout')
+        expect(actual2.children[1].children[0].attr.value).eql('timeout')
+        app.$destroy()
+        done()
+      }, 200)
+    })
+
     it('repeat with array track-by case', () => {
       const name = 'repeat-track-by'
       const sourceCode = readSource(name)