@@ -16,36 +16,39 @@ describe('controller', () => {
1616 } )
1717
1818 it ( 'calls register' , async ( ) => {
19+ @controller
1920 class ControllerRegisterElement extends HTMLElement { }
20- controller ( ControllerRegisterElement )
2121 const instance = document . createElement ( 'controller-register' )
2222 root . appendChild ( instance )
2323 expect ( instance ) . to . be . instanceof ( ControllerRegisterElement )
2424 } )
2525
2626 it ( 'adds data-catalyst to elements' , async ( ) => {
27- controller ( class ControllerDataAttrElement extends HTMLElement { } )
27+ @controller
28+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
29+ class ControllerDataAttrElement extends HTMLElement { }
30+
2831 const instance = document . createElement ( 'controller-data-attr' )
2932 root . appendChild ( instance )
3033 expect ( instance . hasAttribute ( 'data-catalyst' ) ) . to . equal ( true )
3134 expect ( instance . getAttribute ( 'data-catalyst' ) ) . to . equal ( '' )
3235 } )
3336
3437 it ( 'binds controllers before custom connectedCallback behaviour' , async ( ) => {
35- controller (
36- class ControllerBindOrderElement extends HTMLElement {
37- foo ( ) {
38- return ' foo'
39- }
38+ @ controller
39+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
40+ class ControllerBindOrderElement extends HTMLElement {
41+ foo ( ) {
42+ return 'foo'
4043 }
41- )
42- controller (
43- class ControllerBindOrderSubElement extends HTMLElement {
44- connectedCallback ( ) {
45- this . dispatchEvent ( new CustomEvent ( 'loaded' ) )
46- }
44+ }
45+ @ controller
46+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
47+ class ControllerBindOrderSubElement extends HTMLElement {
48+ connectedCallback ( ) {
49+ this . dispatchEvent ( new CustomEvent ( 'loaded' ) )
4750 }
48- )
51+ }
4952
5053 const instance = document . createElement ( 'controller-bind-order' )
5154 replace ( instance , 'foo' , fake ( instance . foo ) )
@@ -59,20 +62,20 @@ describe('controller', () => {
5962 } )
6063
6164 it ( 'binds shadowRoots after connectedCallback behaviour' , async ( ) => {
62- controller (
63- class ControllerBindShadowElement extends HTMLElement {
64- connectedCallback ( ) {
65- this . attachShadow ( { mode : 'open' } )
66- const button = document . createElement ( 'button' )
67- button . setAttribute ( 'data-action' , 'click:controller-bind-shadow#foo ')
68- this . shadowRoot . appendChild ( button )
69- }
70-
71- foo ( ) {
72- return ' foo'
73- }
65+ @ controller
66+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
67+ class ControllerBindShadowElement extends HTMLElement {
68+ connectedCallback ( ) {
69+ this . attachShadow ( { mode : 'open' } )
70+ const button = document . createElement ( 'button ')
71+ button . setAttribute ( 'data-action' , 'click:controller-bind-shadow#foo' )
72+ this . shadowRoot . appendChild ( button )
73+ }
74+
75+ foo ( ) {
76+ return 'foo'
7477 }
75- )
78+ }
7679 const instance = document . createElement ( 'controller-bind-shadow' )
7780 replace ( instance , 'foo' , fake ( instance . foo ) )
7881 root . appendChild ( instance )
@@ -83,13 +86,13 @@ describe('controller', () => {
8386 } )
8487
8588 it ( 'binds auto shadowRoots' , async ( ) => {
86- controller (
87- class ControllerBindAutoShadowElement extends HTMLElement {
88- foo ( ) {
89- return ' foo'
90- }
89+ @ controller
90+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
91+ class ControllerBindAutoShadowElement extends HTMLElement {
92+ foo ( ) {
93+ return 'foo'
9194 }
92- )
95+ }
9396 const instance = document . createElement ( 'controller-bind-auto-shadow' )
9497 const template = document . createElement ( 'template' )
9598 template . setAttribute ( 'data-shadowroot' , 'open' )
@@ -108,30 +111,32 @@ describe('controller', () => {
108111 } )
109112
110113 it ( 'upgrades child decendants when connected' , ( ) => {
111- controller ( class ChildElementElement extends HTMLElement { } )
112- controller (
113- class ParentElementElement extends HTMLElement {
114- connectedCallback ( ) {
115- const child = this . querySelector ( 'child-element' )
116- expect ( child . matches ( ':defined' ) ) . to . equal ( true )
117- }
114+ @controller
115+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
116+ class ChildElementElement extends HTMLElement { }
117+ @controller
118+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
119+ class ParentElementElement extends HTMLElement {
120+ connectedCallback ( ) {
121+ const child = this . querySelector ( 'child-element' )
122+ expect ( child . matches ( ':defined' ) ) . to . equal ( true )
118123 }
119- )
124+ }
120125
121126 // eslint-disable-next-line github/unescaped-html-literal
122127 root . innerHTML = '<parent-element><child-element></child-element></parent-element>'
123128 } )
124129
125130 describe ( 'attrs' , ( ) => {
126131 let attrValues = [ ]
132+ @controller
127133 class AttributeTestElement extends HTMLElement {
128134 foo = 'baz'
129135 attributeChangedCallback ( ) {
130136 attrValues . push ( this . getAttribute ( 'data-foo' ) )
131137 attrValues . push ( this . foo )
132138 }
133139 }
134- controller ( AttributeTestElement )
135140 attr ( AttributeTestElement . prototype , 'foo' )
136141
137142 beforeEach ( ( ) => {
0 commit comments