@@ -3,79 +3,79 @@ import {controller} from '../src/controller.js'
33import { attr } from '../src/attr.js'
44
55describe ( 'Attr' , ( ) => {
6- @controller
7- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8- class InitializeAttrTest extends HTMLElement {
9- @attr fooBar = 'hello'
10- fooBaz = 1
11-
12- getCount = 0
13- setCount = 0
14- #bing = 'world'
15- get bingBaz ( ) {
16- this . getCount += 1
17- return this . #bing
18- }
19- @attr set bingBaz ( value : string ) {
20- this . setCount += 1
21- this . #bing = value
6+ {
7+ @controller
8+ class InitializeAttrTest extends HTMLElement {
9+ @attr fooBar = 'hello'
10+ fooBaz = 1
11+
12+ getCount = 0
13+ setCount = 0
14+ #bing = 'world'
15+ get bingBaz ( ) {
16+ this . getCount += 1
17+ return this . #bing
18+ }
19+ @attr set bingBaz ( value : string ) {
20+ this . setCount += 1
21+ this . #bing = value
22+ }
2223 }
23- }
2424
25- let instance
26- beforeEach ( async ( ) => {
27- instance = await fixture ( html `< initialize-attr-test /> ` )
28- } )
25+ let instance : InitializeAttrTest
26+ beforeEach ( async ( ) => {
27+ instance = await fixture ( html `< initialize-attr-test /> ` )
28+ } )
2929
30- it ( 'does not error during creation' , ( ) => {
31- document . createElement ( 'initialize-attr-test' )
32- } )
30+ it ( 'does not error during creation' , ( ) => {
31+ document . createElement ( 'initialize-attr-test' )
32+ } )
3333
34- it ( 'does not alter field values from their initial value' , ( ) => {
35- expect ( instance ) . to . have . property ( 'fooBar' , 'hello' )
36- expect ( instance ) . to . have . property ( 'fooBaz' , 1 )
37- expect ( instance ) . to . have . property ( 'bingBaz' , 'world' )
38- } )
34+ it ( 'does not alter field values from their initial value' , ( ) => {
35+ expect ( instance ) . to . have . property ( 'fooBar' , 'hello' )
36+ expect ( instance ) . to . have . property ( 'fooBaz' , 1 )
37+ expect ( instance ) . to . have . property ( 'bingBaz' , 'world' )
38+ } )
3939
40- it ( 'reflects the initial value as an attribute, if not present' , ( ) => {
41- expect ( instance ) . to . have . attribute ( 'data-foo-bar' , 'hello' )
42- expect ( instance ) . to . not . have . attribute ( 'data-foo-baz' )
43- expect ( instance ) . to . have . attribute ( 'data-bing-baz' , 'world' )
44- } )
40+ it ( 'reflects the initial value as an attribute, if not present' , ( ) => {
41+ expect ( instance ) . to . have . attribute ( 'data-foo-bar' , 'hello' )
42+ expect ( instance ) . to . not . have . attribute ( 'data-foo-baz' )
43+ expect ( instance ) . to . have . attribute ( 'data-bing-baz' , 'world' )
44+ } )
4545
46- it ( 'prioritises the value in the attribute over the property' , async ( ) => {
47- instance = await fixture ( html `< initialize-attr-test data-foo-bar ="goodbye " data-bing-baz ="universe " /> ` )
48- expect ( instance ) . to . have . property ( 'fooBar' , 'goodbye' )
49- expect ( instance ) . to . have . attribute ( 'data-foo-bar' , 'goodbye' )
50- expect ( instance ) . to . have . property ( 'bingBaz' , 'universe' )
51- expect ( instance ) . to . have . attribute ( 'data-bing-baz' , 'universe' )
52- } )
46+ it ( 'prioritises the value in the attribute over the property' , async ( ) => {
47+ instance = await fixture ( html `< initialize-attr-test data-foo-bar ="goodbye " data-bing-baz ="universe " /> ` )
48+ expect ( instance ) . to . have . property ( 'fooBar' , 'goodbye' )
49+ expect ( instance ) . to . have . attribute ( 'data-foo-bar' , 'goodbye' )
50+ expect ( instance ) . to . have . property ( 'bingBaz' , 'universe' )
51+ expect ( instance ) . to . have . attribute ( 'data-bing-baz' , 'universe' )
52+ } )
5353
54- it ( 'changes the property when the attribute changes' , async ( ) => {
55- instance . setAttribute ( 'data-foo-bar' , 'goodbye' )
56- await Promise . resolve ( )
57- expect ( instance ) . to . have . property ( 'fooBar' , 'goodbye' )
58- instance . setAttribute ( 'data-bing-baz' , 'universe' )
59- await Promise . resolve ( )
60- expect ( instance ) . to . have . property ( 'bingBaz' , 'universe' )
61- } )
54+ it ( 'changes the property when the attribute changes' , async ( ) => {
55+ instance . setAttribute ( 'data-foo-bar' , 'goodbye' )
56+ await Promise . resolve ( )
57+ expect ( instance ) . to . have . property ( 'fooBar' , 'goodbye' )
58+ instance . setAttribute ( 'data-bing-baz' , 'universe' )
59+ await Promise . resolve ( )
60+ expect ( instance ) . to . have . property ( 'bingBaz' , 'universe' )
61+ } )
6262
63- it ( 'changes the attribute when the property changes' , ( ) => {
64- instance . fooBar = 'goodbye'
65- expect ( instance ) . to . have . attribute ( 'data-foo-bar' , 'goodbye' )
66- instance . bingBaz = 'universe'
67- expect ( instance ) . to . have . attribute ( 'data-bing-baz' , 'universe' )
68- } )
63+ it ( 'changes the attribute when the property changes' , ( ) => {
64+ instance . fooBar = 'goodbye'
65+ expect ( instance ) . to . have . attribute ( 'data-foo-bar' , 'goodbye' )
66+ instance . bingBaz = 'universe'
67+ expect ( instance ) . to . have . attribute ( 'data-bing-baz' , 'universe' )
68+ } )
69+ }
6970
7071 describe ( 'types' , ( ) => {
7172 it ( 'infers boolean types from property and uses has/toggleAttribute' , async ( ) => {
7273 @controller
73- // eslint-disable-next-line @typescript-eslint/no-unused-vars
7474 class BooleanAttrTest extends HTMLElement {
7575 @attr fooBar = false
7676 }
7777
78- instance = await fixture ( html `< boolean-attr-test /> ` )
78+ const instance = await fixture < BooleanAttrTest > ( html `< boolean-attr-test /> ` )
7979
8080 expect ( instance ) . to . have . property ( 'fooBar' , false )
8181 expect ( instance ) . to . not . have . attribute ( 'data-foo-bar' )
@@ -104,7 +104,6 @@ describe('Attr', () => {
104104
105105 it ( 'avoids infinite loops' , async ( ) => {
106106 @controller
107- // eslint-disable-next-line @typescript-eslint/no-unused-vars
108107 class LoopAttrTest extends HTMLElement {
109108 count = 0
110109 @attr
@@ -115,7 +114,8 @@ describe('Attr', () => {
115114 this . count += 1
116115 }
117116 }
118- instance = await fixture ( html `< loop-attr-test /> ` )
117+
118+ const instance = await fixture < LoopAttrTest > ( html `< loop-attr-test /> ` )
119119
120120 expect ( instance ) . to . have . property ( 'fooBar' )
121121 instance . fooBar = 1
@@ -127,13 +127,13 @@ describe('Attr', () => {
127127
128128 describe ( 'naming' , ( ) => {
129129 @controller
130- // eslint-disable-next-line @typescript-eslint/no-unused-vars
131130 class NamingAttrTest extends HTMLElement {
132131 @attr fooBarBazBing = 'a'
133132 @attr URLBar = 'b'
134133 @attr ClipX = 'c'
135134 }
136135
136+ let instance : NamingAttrTest
137137 beforeEach ( async ( ) => {
138138 instance = await fixture ( html `< naming-attr-test /> ` )
139139 } )
0 commit comments