Skip to content

Commit 992299b

Browse files
committed
Make tests pass with coconut.vdom
1 parent 4006c62 commit 992299b

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ jobs:
1515
haxe-version:
1616
- stable
1717
- nightly
18-
target:
18+
target:
1919
- interp
2020
- neko
2121
- node
2222
- js
23+
- js -lib coconut.vdom
2324
- cpp
2425
- php
2526
- jvm
@@ -29,7 +30,7 @@ jobs:
2930
steps:
3031
- name: Check out repo
3132
uses: actions/checkout@v2
32-
33+
3334
- name: Get yarn cache directory path
3435
id: yarn-cache-dir-path
3536
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -41,34 +42,34 @@ jobs:
4142
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
4243
restore-keys: |
4344
${{ runner.os }}-yarn-
44-
45+
4546
- name: Cache Haxe
4647
uses: actions/cache@v1
4748
with:
4849
path: ${{ startsWith(runner.os, 'windows') && '%AppData%' || '~/haxe' }}
4950
key: ${{ runner.os }}-haxe
50-
51+
5152
- name: Install Lix
5253
uses: lix-pm/setup-lix@master
53-
54+
5455
- name: Install Haxe
5556
run: lix install haxe ${{ matrix.haxe-version }}
56-
57+
5758
- name: Install Haxe Libraries
5859
run: lix download
59-
60+
6061
- name: Run Test
6162
run: lix run travix ${{ matrix.target }}
6263

6364
release:
6465
runs-on: ubuntu-latest
6566
needs: test
6667
if: startsWith(github.ref, 'refs/tags/') # consider using the "release" event. see: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release
67-
68+
6869
steps:
6970
- name: Check out repo
7071
uses: actions/checkout@v2
71-
72+
7273
- name: Get yarn cache directory path
7374
id: yarn-cache-dir-path
7475
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -80,24 +81,23 @@ jobs:
8081
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
8182
restore-keys: |
8283
${{ runner.os }}-yarn-
83-
84+
8485
- name: Cache Haxe
8586
uses: actions/cache@v1
8687
with:
8788
path: ${{ startsWith(runner.os, 'windows') && '%AppData%' || '~/haxe' }}
8889
key: ${{ runner.os }}-haxe
89-
90+
9091
- name: Install Lix
9192
uses: lix-pm/setup-lix@master
92-
93+
9394
- name: Install Haxe
9495
run: lix install haxe stable
95-
96+
9697
- name: Install Haxe Libraries
9798
run: lix download
98-
99+
99100
- name: Release to Haxelib
100101
run: lix run travix release
101102
env:
102103
HAXELIB_AUTH: ${{ secrets.HAXELIB_AUTH }}
103-

haxe_libraries/coconut.vdom.hxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# @install: lix --silent download "gh://github.com/MVCoconut/coconut.vdom#058fbb7b86580043bea3335ab0a58f863c143b72" into coconut.vdom/0.8.1/github/058fbb7b86580043bea3335ab0a58f863c143b72
1+
# @install: lix --silent download "gh://github.com/MVCoconut/coconut.vdom#4735d72f0faadff2e949a3901791ff97e59c520b" into coconut.vdom/0.9.0/github/4735d72f0faadff2e949a3901791ff97e59c520b
22
-lib coconut.diffing
33
-lib xDOM
4-
-cp ${HAXE_LIBCACHE}/coconut.vdom/0.8.1/github/058fbb7b86580043bea3335ab0a58f863c143b72/src
5-
-D coconut.vdom=0.8.1
4+
-cp ${HAXE_LIBCACHE}/coconut.vdom/0.9.0/github/4735d72f0faadff2e949a3901791ff97e59c520b/src
5+
-D coconut.vdom=0.9.0

tests/TodoMvc.hx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class TodoMvc {
5454

5555
function walk(native:Native, cb:Native->Void) {
5656
#if coconut.vdom
57-
#error
57+
cb(native);
58+
for (e in native.childNodes)
59+
walk(cast e, cb);
5860
#else
5961
native.each(cb);
6062
#end
@@ -102,7 +104,7 @@ class TodoMvc {
102104
return asserts.done();
103105
}
104106

105-
@:include public function testHydration() {
107+
public function testHydration() {
106108

107109
function compare(markup) {
108110

@@ -111,20 +113,31 @@ class TodoMvc {
111113
nodes = [];
112114

113115
for (hydrate in [false, true]) {
114-
new Root(root, DummyApplicator.INST, markup, hydrate);
116+
new Root(
117+
cast root,
118+
#if coconut.vdom
119+
@:privateAccess Renderer.BACKEND // meh
120+
#else DummyApplicator.INST #end,
121+
markup,
122+
hydrate
123+
);
115124
if (hydrate) {
116125
asserts.assert(root.innerHTML == innerHTML);
117126
walk(root, n -> {
118127
asserts.assert(nodes.shift() == n);
128+
#if !coconut.vdom
119129
if (n != root)
120130
asserts.assert(n.wet);
131+
#end
121132
});
122133
}
123134
else {
124135
innerHTML = root.innerHTML;
125136
walk(root, n -> {
126137
nodes.push(n);
138+
#if !coconut.vdom
127139
asserts.assert(!n.wet);
140+
#end
128141
});
129142
}
130143
}
@@ -161,7 +174,7 @@ class TodoMvc {
161174
'));
162175

163176
asserts.assert(TodoListView.mounted == lists + 4);
164-
asserts.assert(TodoItemView.mounted == lists + 10);
177+
asserts.assert(TodoItemView.mounted == items + 10);
165178

166179
return asserts.done();
167180
}

0 commit comments

Comments
 (0)