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 9, 2023
1 parent f9b6846 commit 48f4d60
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 @@ -20,7 +20,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 @@ -177,7 +177,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 @@ -209,7 +209,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 48f4d60

Please sign in to comment.