1+ /**
2+ * @license
3+ * Copyright 2017 Google Inc. All rights reserved.
4+ *
5+ * Licensed under the Apache License, Version 2.0 (the "License");
6+ * you may not use this file except in compliance with the License.
7+ * You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ */
17+
18+ import { expect , test } from '@playwright/test' ;
19+ import { getProp } from "./util" ;
20+
21+ test . beforeEach ( async ( { page} ) => {
22+ await page . goto ( '/react' ) ;
23+ } )
24+
25+ test . describe ( 'advanced support' , ( ) => {
26+ test . describe ( 'attributes and properties' , ( ) => {
27+ test ( 'will pass array data as a property' , async ( { page} ) => {
28+ const ce = page . locator ( '#ce-with-properties' ) ;
29+ expect ( await getProp ( ce , 'arr' ) ) . toEqual ( [ 'R' , 'e' , 'a' , 'c' , 't' ] )
30+ } )
31+
32+ test ( 'will pass object data as a property' , async ( { page} ) => {
33+ const ce = page . locator ( '#ce-with-properties' ) ;
34+ expect ( await getProp ( ce , 'obj' ) ) . toEqual ( { org : "facebook" , repo : "react" } )
35+ } )
36+
37+ test ( "will pass object data to a camelCase-named property" , async ( { page} ) => {
38+ const ce = page . locator ( '#ce-with-properties' ) ;
39+ expect ( await getProp ( ce , 'camelCaseObj' ) ) . toEqual ( { label : "passed" } )
40+ } )
41+ } ) ;
42+
43+ test . describe ( 'events' , ( ) => {
44+
45+ test ( "can declaratively listen to a lowercase DOM event dispatched by a Custom Element" , async ( { page} ) => {
46+ const ce = page . locator ( '#ce-with-declarative-event' ) ;
47+ await expect ( page . getByText ( / l o w e r c a s e : / ) ) . toHaveText ( / f a l s e / ) ;
48+ await ce . click ( ) ;
49+ await expect ( page . getByText ( / l o w e r c a s e : / ) ) . toHaveText ( / t r u e / ) ;
50+ } )
51+
52+ test ( "can declaratively listen to a camelCase DOM event dispatched by a Custom Element" , async ( { page} ) => {
53+ const ce = page . locator ( '#ce-with-declarative-event' ) ;
54+ await expect ( page . getByText ( / c a m e l C a s e : / ) ) . toHaveText ( / f a l s e / ) ;
55+ await ce . click ( ) ;
56+ await expect ( page . getByText ( / c a m e l C a s e : / ) ) . toHaveText ( / t r u e / ) ;
57+ } )
58+ test ( "can declaratively listen to a kebab-case DOM event dispatched by a Custom Element" , async ( { page} ) => {
59+ const ce = page . locator ( '#ce-with-declarative-event' ) ;
60+ await expect ( page . getByText ( / k e b a b - c a s e : / ) ) . toHaveText ( / f a l s e / ) ;
61+ await ce . click ( ) ;
62+ await expect ( page . getByText ( / k e b a b - c a s e : / ) ) . toHaveText ( / t r u e / ) ;
63+ } )
64+ test ( "can declaratively listen to a CAPScase DOM event dispatched by a Custom Element" , async ( { page} ) => {
65+ const ce = page . locator ( '#ce-with-declarative-event' ) ;
66+ await expect ( page . getByText ( / C A P S c a s e : / ) ) . toHaveText ( / f a l s e / ) ;
67+ await ce . click ( ) ;
68+ await expect ( page . getByText ( / C A P S c a s e : / ) ) . toHaveText ( / t r u e / ) ;
69+ } )
70+ test ( "can declaratively listen to a PascalCase DOM event dispatched by a Custom Element" , async ( { page} ) => {
71+ const ce = page . locator ( '#ce-with-declarative-event' ) ;
72+ await expect ( page . getByText ( / P a s c a l C a s e : / ) ) . toHaveText ( / f a l s e / ) ;
73+ await ce . click ( ) ;
74+ await expect ( page . getByText ( / P a s c a l C a s e : / ) ) . toHaveText ( / t r u e / ) ;
75+ } )
76+ } ) ;
77+ } )
0 commit comments