Caleb Porzio 1 tahun lalu
induk
melakukan
9e1ec53a9d
2 mengubah file dengan 15 tambahan dan 0 penghapusan
  1. 14 0
      tests/cypress/integration/plugins/anchor.spec.js
  2. 1 0
      tests/cypress/spec.html

+ 14 - 0
tests/cypress/integration/plugins/anchor.spec.js

@@ -0,0 +1,14 @@
+import { haveAttribute, haveComputedStyle, html, notHaveAttribute, test } from '../../utils'
+
+test('can anchor an element',
+    [html`
+        <div x-data>
+            <button x-ref="foo">toggle</button>
+            <h1 x-anchor="$refs.foo">contents</h1>
+        </div>
+    `],
+    ({ get }, reload) => {
+        get('h1').should(haveComputedStyle('position', 'absolute'))
+        get('h1').should(haveAttribute('style', 'left: 17.2772px; top: 29.5px; position: absolute;'))
+    },
+)

+ 1 - 0
tests/cypress/spec.html

@@ -11,6 +11,7 @@
     <script src="/../../packages/focus/dist/cdn.js"></script>
     <script src="/../../packages/intersect/dist/cdn.js"></script>
     <script src="/../../packages/collapse/dist/cdn.js"></script>
+    <script src="/../../packages/anchor/dist/cdn.js"></script>
     <script src="/../../packages/mask/dist/cdn.js"></script>
     <script src="/../../packages/ui/dist/cdn.js"></script>
     <script>