Skip to content

Commit

Permalink
improve the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
huang2002 committed Feb 10, 2019
1 parent f526036 commit 2426dfa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
22 changes: 22 additions & 0 deletions test/src/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
interface CounterStore {
value: number;
}

const Counter = HUI.define<{}, HUI.Store<CounterStore, {}>, HUI.EmptyStore>('Counter', {

state: ['value'],

defaultStore: {
value: 0
},

render(props, store) {
return (
<HUI.Fragment>
<button onclick={() => store.inc('value')}>Click me!</button>
<p>Count: {store.get('value')}</p>
</HUI.Fragment>
);
}

});
3 changes: 3 additions & 0 deletions test/src/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const Dialog = HUI.define<{}, HUI.Store<DialogStore, DialogStoreHandlers>, HUI.E
{store.get('on') && [
<p>(Dialog window is shown.)</p>,
<HUI.Portal>
{undefined}
<p attr={{ style: 'color: blue;' }}>[Dialog window]</p>
{null}
{Object}
</HUI.Portal>
]}
</HUI.Fragment>
Expand Down
10 changes: 9 additions & 1 deletion test/src/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type TestContext = HUI.Store<{

const SVG_NS = 'http://www.w3.org/2000/svg';

HUI.tick = cb => { setTimeout(cb, 500) };

HUI.render<TestContext>(
(

Expand All @@ -18,6 +20,10 @@ HUI.render<TestContext>(

<hr />

<Counter />

<hr />

Global Timer:<br />
<Timer start={100} />

Expand All @@ -37,7 +43,9 @@ HUI.render<TestContext>(

<p>SVG test:</p>

<svg xmlns={SVG_NS} attr={{ width: '100', height: '100' }} style={{ 'box-shadow': '0 0 10px #999' }}>
<svg xmlns={SVG_NS}
attr={{ width: '100', height: '100' }}
style={{ 'box-shadow': '0 0 10px #999' }}>
<path
xmlns={SVG_NS}
d="M 10 40 C 20 80 80 80 90 40"
Expand Down

0 comments on commit 2426dfa

Please sign in to comment.