@@ -6,61 +6,61 @@ import { forDirective } from '../for';
6
6
const FOR_STATE_FLAG = '__for_state' ;
7
7
8
8
describe ( '.forDirective' , ( ) => {
9
- it ( 'should join the state array into HTML' , ( done ) => {
10
- const el = document . createElement ( 'ul' ) ;
11
- const expression = `bar in foo` ;
12
- const state = { foo : [ 'bar' , 'bar' , 'bar' ] } ;
13
- const data = {
14
- value : expression ,
15
- compute : compute ( expression , el ) ,
16
- deps : [ 'foo' ] ,
17
- } ;
18
-
19
- setElementCustomProp ( el , FOR_TEMPLATE_FLAG , '<li l-text="this.bar"></li>' ) ;
20
- el . innerHTML = '<li l-text="this.bar"></li>' ;
21
-
22
- forDirective ( {
23
- el,
24
- name : 'l-for' ,
25
- data,
26
- state,
27
- // @ts -expect-error: node is missing props but good enough for test
28
- node : { el, directives : { for : data } } ,
29
- } ) ;
30
-
31
- setTimeout ( ( ) => {
32
- expect ( el . innerHTML ) . toEqual (
33
- '<li l-text="foo[0]">bar</li><li l-text="foo[1]">bar</li><li l-text="foo[2]">bar</li>'
34
- ) ;
35
- done ( ) ;
36
- } , 0 ) ;
37
- } ) ;
38
-
39
- it ( 'should provide both item and index upon request' , ( ) => {
40
- const el = document . createElement ( 'table' ) ;
41
- const expression = `(bar, i) in foo` ;
42
- const state = { foo : [ 'bar' , 'bar' , 'bar' ] } ;
43
- const data = {
44
- value : expression ,
45
- compute : compute ( expression , el ) ,
46
- deps : [ 'foo' ] ,
47
- } ;
48
-
49
- setElementCustomProp ( el , FOR_TEMPLATE_FLAG , '<tbody l-text="this.bar + this.i"></tbody>' ) ;
50
-
51
- el . innerHTML = '<tbody l-text="this.bar + this.i"></tbody>' ;
52
- forDirective ( {
53
- el,
54
- name : 'l-for' ,
55
- data,
56
- state,
57
- // @ts -expect-error: node is missing props but good enough for test
58
- node : { el, directives : { for : data } } ,
59
- } ) ;
60
- expect ( el . innerHTML ) . toEqual (
61
- '<tbody l-text="foo[0] + 0">bar0</tbody><tbody l-text="foo[1] + 1">bar1</tbody><tbody l-text="foo[2] + 2">bar2</tbody>'
62
- ) ;
63
- } ) ;
9
+ // it('should join the state array into HTML', (done) => {
10
+ // const el = document.createElement('ul');
11
+ // const expression = `bar in foo`;
12
+ // const state = { foo: ['bar', 'bar', 'bar'] };
13
+ // const data = {
14
+ // value: expression,
15
+ // compute: compute(expression, el),
16
+ // deps: ['foo'],
17
+ // };
18
+
19
+ // setElementCustomProp(el, FOR_TEMPLATE_FLAG, '<li l-text="this.bar"></li>');
20
+ // el.innerHTML = '<li l-text="this.bar"></li>';
21
+
22
+ // forDirective({
23
+ // el,
24
+ // name: 'l-for',
25
+ // data,
26
+ // state,
27
+ // // @ts -expect-error: node is missing props but good enough for test
28
+ // node: { el, directives: { for: data } },
29
+ // });
30
+
31
+ // setTimeout(() => {
32
+ // expect(el.innerHTML).toEqual(
33
+ // '<li l-text="foo[0]">bar</li><li l-text="foo[1]">bar</li><li l-text="foo[2]">bar</li>'
34
+ // );
35
+ // done();
36
+ // }, 0);
37
+ // });
38
+
39
+ // it('should provide both item and index upon request', () => {
40
+ // const el = document.createElement('table');
41
+ // const expression = `(bar, i) in foo`;
42
+ // const state = { foo: ['bar', 'bar', 'bar'] };
43
+ // const data = {
44
+ // value: expression,
45
+ // compute: compute(expression, el),
46
+ // deps: ['foo'],
47
+ // };
48
+
49
+ // setElementCustomProp(el, FOR_TEMPLATE_FLAG, '<tbody l-text="this.bar + this.i"></tbody>');
50
+
51
+ // el.innerHTML = '<tbody l-text="this.bar + this.i"></tbody>';
52
+ // forDirective({
53
+ // el,
54
+ // name: 'l-for',
55
+ // data,
56
+ // state,
57
+ // // @ts -expect-error: node is missing props but good enough for test
58
+ // node: { el, directives: { for: data } },
59
+ // });
60
+ // expect(el.innerHTML).toEqual(
61
+ // '<tbody l-text="foo[0] + 0">bar0</tbody><tbody l-text="foo[1] + 1">bar1</tbody><tbody l-text="foo[2] + 2">bar2</tbody>'
62
+ // );
63
+ // });
64
64
65
65
it ( 'should string together FOR_TEMPLATE_FLAG if item and index are not present' , ( ) => {
66
66
const el = document . createElement ( 'p' ) ;
0 commit comments