Skip to content

Commit

Permalink
test: include test
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Dec 30, 2024
1 parent c9c564c commit 2dfdf0b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/radix-vue/src/PinInput/PinInput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ describe('given default PinInput', () => {
expect(await axe(wrapper.element)).toHaveNoViolations()
})

it('should display input placeholders', () => {
expect(inputs[0].element.placeholder).toBe('') // first input was focused thus not showing placeholder
expect(inputs[1].element.placeholder).toBe('*')
expect(inputs[2].element.placeholder).toBe('*')
expect(inputs[3].element.placeholder).toBe('*')
expect(inputs[4].element.placeholder).toBe('*')
})

describe('after user input', () => {
beforeEach(async () => {
await userEvent.keyboard('test')
Expand Down Expand Up @@ -143,6 +151,22 @@ describe('given default PinInput', () => {
it('should emit \'complete\' with the result', () => {
expect(wrapper.emitted('complete')?.[0]?.[0]).toStrictEqual(['a', 'p', 'p', 'l', 'e'])
})

describe('after resetting value', async () => {
beforeEach(async () => {
await userEvent.keyboard('apple')
const button = wrapper.find('button')
await button.trigger('click')
})

it('should display input placeholders', () => {
expect(inputs[0].element.placeholder).toBe('*')
expect(inputs[1].element.placeholder).toBe('*')
expect(inputs[2].element.placeholder).toBe('*')
expect(inputs[3].element.placeholder).toBe('*')
expect(inputs[4].element.placeholder).toBe('*')
})
})
})
})

Expand Down
5 changes: 5 additions & 0 deletions packages/radix-vue/src/PinInput/story/_PinInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const value = ref<string[]>([])
<PinInputRoot
v-bind="{ ...props, ...useEmitAsProps(emits) }"
v-model="value"
placeholder="*"
class="flex gap-2 items-center"
>
<PinInputInput
Expand All @@ -24,4 +25,8 @@ const value = ref<string[]>([])
:index="index"
/>
</PinInputRoot>

<button @click="value = []">
Reset value
</button>
</template>

0 comments on commit 2dfdf0b

Please sign in to comment.