Skip to content

Commit

Permalink
Rename setSelection to toggleSelection
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Feb 8, 2023
1 parent ba25352 commit 759548b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
size="large"
class="oc-flex-inline oc-p-s"
:model-value="isResourceSelected(resource)"
@click.stop.prevent="setSelection(resource)"
@click.stop.prevent="toggleSelection(resource)"
/>
</template>
<template #imageField>
Expand Down Expand Up @@ -175,7 +175,7 @@ export default defineComponent({
return props.selectedIds.includes(resource.id)
}
const setSelection = (resource) => {
const toggleSelection = (resource) => {
const selectedIds = !isResourceSelected(resource)
? [...props.selectedIds, resource.id]
: props.selectedIds.filter((id) => id !== resource.id)
Expand Down Expand Up @@ -207,7 +207,7 @@ export default defineComponent({
showContextMenu,
tileRefs,
isResourceSelected,
setSelection,
toggleSelection,
getResourceCheckboxLabel
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('ResourceTiles component', () => {

it('emits update:selectedIds event on resource selection and sets the selection', () => {
const wrapper = getWrapper({ data: spacesResources, selectedIds: [spacesResources[0].id] })
wrapper.vm.setSelection(spacesResources[0])
wrapper.vm.toggleSelection(spacesResources[0])
expect(wrapper.find('oc-tile').attributes()['is-resource-selected']).toEqual('true')
expect(wrapper.emitted('update:selectedIds')).toBeTruthy()
})
Expand Down

0 comments on commit 759548b

Please sign in to comment.