소스 검색

fix(reset): allow resetting null stores

Ryan Chandler 4 년 전
부모
커밋
d707007c27
9개의 변경된 파일19개의 추가작업 그리고 6개의 파일을 삭제
  1. 0 0
      dist/spruce.js
  2. 0 0
      dist/spruce.js.map
  3. 0 0
      dist/spruce.module.js
  4. 0 0
      dist/spruce.module.js.map
  5. 0 0
      dist/spruce.umd.js
  6. 0 0
      dist/spruce.umd.js.map
  7. 1 1
      src/index.js
  8. 9 2
      tests/cypress/fixtures/reset/index.html
  9. 9 3
      tests/cypress/integration/reset.spec.js

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/spruce.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/spruce.js.map


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/spruce.module.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/spruce.module.js.map


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/spruce.umd.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/spruce.umd.js.map


+ 1 - 1
src/index.js

@@ -114,7 +114,7 @@ const Spruce = {
     },
 
     reset(name, state) {
-        if (! this.stores[name]) {
+        if (this.stores[name] === undefined) {
             return;
         }
         

+ 9 - 2
tests/cypress/fixtures/reset/index.html

@@ -4,14 +4,21 @@
     </head>
     <body>
         <div x-data>
-            <span x-text="$store.foo.bar"></span>
-            <button x-on:click="Spruce.reset('foo', { bar: 'boo' })"></button>
+            <span data-basic x-text="$store.foo.bar"></span>
+            <button data-basic-update x-on:click="Spruce.reset('foo', { bar: 'boo' })"></button>
+        </div>
+
+        <div x-data>
+            <span data-null-store x-text="$store.example?.name"></span>
+            <button data-null-store-update x-on:click="Spruce.reset('example', { name: 'Ryan' })"></button>
         </div>
 
         <script src="/dist/spruce.umd.js"></script>
 
         <script>
             Spruce.store('foo', { bar: 'car' })
+
+            Spruce.store('example', null)
         </script>
     </body>
 </html>

+ 9 - 3
tests/cypress/integration/reset.spec.js

@@ -4,10 +4,16 @@ describe('reset', () => {
     it('should re-render after state reset', () => {
         cy.visit('/tests/cypress/fixtures/reset')
 
-        cy.get('span').should('have.text', 'car')
+        cy.get('span[data-basic]').should('have.text', 'car')
 
-        cy.get('button').click()
+        cy.get('button[data-basic-update]').click()
 
-        cy.get('span').should('have.text', 'boo')
+        cy.get('span[data-basic]').should('have.text', 'boo')
+
+        cy.get('[data-null-store]').should('have.text', '')
+
+        cy.get('[data-null-store-update]').click()
+
+        cy.get('[data-null-store]').should('have.text', 'Ryan')
     })
 })

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.