Browse Source

Add failing test (#2370)

Simone Todaro 3 years ago
parent
commit
e639914c3b
1 changed files with 22 additions and 1 deletions
  1. 22 1
      tests/cypress/integration/plugins/collapse.spec.js

+ 22 - 1
tests/cypress/integration/plugins/collapse.spec.js

@@ -32,7 +32,6 @@ test('@click.away with x-collapse (prevent race condition)',
     }
 )
 
-
 test('@click.away with x-collapse and borders (prevent race condition)',
     html`
         <div x-data="{ show: false }">
@@ -47,3 +46,25 @@ test('@click.away with x-collapse and borders (prevent race condition)',
         get('h1').should(haveAttribute('style', 'height: auto;'))
     }
 )
+
+// https://github.com/alpinejs/alpine/issues/2335
+test('double-click on x-collapse does not mix styles up',
+    [html`
+        <div x-data="{ expanded: false }">
+            <button @click="expanded = ! expanded">toggle</button>
+            <h1 x-show="expanded" x-collapse>contents</h1>
+        </div>
+    `],
+    ({ get }, reload) => {
+        get('h1').should(haveComputedStyle('height', '0px'))
+        get('h1').should(haveAttribute('style', 'height: 0px; overflow: hidden;'))
+        get('button').click()
+        get('button').click()
+        get('h1').should(haveAttribute('style', 'height: 0px; overflow: hidden;'))
+        get('button').click()
+        get('h1').should(haveAttribute('style', 'height: auto;'))
+        get('button').click()
+        get('button').click()
+        get('h1').should(haveAttribute('style', 'height: auto;'))
+    },
+)