Skip to content

Commit

Permalink
feat: [divider] - add data-test attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgoud committed Nov 2, 2023
1 parent 0a50e2b commit b5acdc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/components/divider/src/divider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export const dividerProps = buildProps({
required: false,
default: PuikDividerOrientation.HORIZONTAL,
},
dataTest: {
type: String,
required: false,
default: undefined,
},
} as const)

export type DividerProps = ExtractPropTypes<typeof dividerProps>
Expand Down
2 changes: 2 additions & 0 deletions packages/components/divider/src/divider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
<hr
v-if="props.orientation === PuikDividerOrientation.HORIZONTAL"
class="puik-divider puik-divider--horizontal"
:data-test="dataTest != undefined ? `horizontal-${dataTest}` : ''"
/>
<div
v-if="props.orientation === PuikDividerOrientation.VERTICAL"
class="puik-divider puik-divider--vertical"
:data-test="dataTest != undefined ? `vertical-${dataTest}` : ''"
></div>
</template>

Expand Down
6 changes: 6 additions & 0 deletions packages/components/divider/test/divider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ describe('Divider tests', () => {
factory()
expect(wrapper).toBeTruthy()
})

it('should be a vertical divider', () => {
factory({ orientation: 'vertical' })
expect(findDivider().classes()).toContain('puik-divider--vertical')
})

it('the value of the data-test attribute should be "vertical-test"', () => {
factory({ orientation: 'vertical', dataTest: 'test' })
expect(findDivider().attributes('data-test')).toBe('vertical-test')
})
})

0 comments on commit b5acdc9

Please sign in to comment.