Browse Source

tests(persistence): test custom drivers

Ryan Chandler 4 years ago
parent
commit
b56538b1f0

File diff suppressed because it is too large
+ 0 - 0
dist/spruce.js


File diff suppressed because it is too large
+ 0 - 0
dist/spruce.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/spruce.module.js


File diff suppressed because it is too large
+ 0 - 0
dist/spruce.module.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/spruce.umd.js


File diff suppressed because it is too large
+ 0 - 0
dist/spruce.umd.js.map


+ 21 - 0
tests/cypress/fixtures/persistence/drivers.html

@@ -0,0 +1,21 @@
+<html>
+    <head>
+        <script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.js" defer></script>
+    </head>
+    <body>
+        <div x-data>
+            <p x-text="$store.persisted.foo"></p>
+            <button @click="$store.persisted.foo = 'car'"></button>
+        </div>
+
+        <script src="/dist/spruce.umd.js"></script>
+
+        <script>
+            Spruce.persistUsing(window.sessionStorage)
+            
+            Spruce.store('persisted', {
+                foo: 'bar'
+            }, true)
+        </script>
+    </body>
+</html>

+ 13 - 0
tests/cypress/integration/persistence.spec.js

@@ -20,6 +20,19 @@ describe('persisted stores', () => {
         cy.get('p').should('have.text', 'car')
     })
 
+    it('should persist data between visits using a custom driver', () => {
+        cy.visit('/tests/cypress/fixtures/persistence/check-persisted.html')
+
+        cy.get('p').should('have.text', 'bar')
+
+        cy.get('button').click()
+        cy.get('p').should('have.text', 'car')
+
+        cy.reload()
+
+        cy.get('p').should('have.text', 'car')
+    })
+
     it('should be able to call store methods when persisted', () => {
         cy.visit('/tests/cypress/fixtures/persistence/store-methods.html')
 

Some files were not shown because too many files changed in this diff