Skip to content

Commit

Permalink
feat(#429): add id and uuid watch (#430)
Browse files Browse the repository at this point in the history
* feat(#429): add id and uuid watch

* chore(#429): add test coverage
  • Loading branch information
Decipher authored Feb 3, 2022
1 parent 6d763ce commit 1db9584
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-bottles-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"druxt-blocks": minor
---

feat(#429): Added watch for ID and UUID to the DruxtBlock component.
10 changes: 10 additions & 0 deletions packages/blocks/src/components/DruxtBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ export default {
block: ({ resource }) => (resource || {}).data,
},
watch: {
id() {
this.$fetch()
},
uuid() {
this.$fetch()
}
},
methods: {
/**
* Maps Vuex action to methods.
Expand Down
11 changes: 11 additions & 0 deletions packages/blocks/test/components/DruxtBlock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,15 @@ describe('Component - DruxtBlock', () => {
block: wrapper.vm.block,
})
})

test('watch - props $fetch', async () => {
const $fetch = jest.fn()
expect($fetch).toHaveBeenCalledTimes(0)

DruxtBlock.watch.id.call({ $fetch })
expect($fetch).toHaveBeenCalledTimes(1)

DruxtBlock.watch.uuid.call({ $fetch })
expect($fetch).toHaveBeenCalledTimes(2)
})
})

0 comments on commit 1db9584

Please sign in to comment.