Skip to content

Commit

Permalink
feat(text-input): initial setup & input label
Browse files Browse the repository at this point in the history
Setup index.js, test and .vue files along with initial label
state and test
  • Loading branch information
felipebritor committed Apr 10, 2023
1 parent de2206c commit ed2d603
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/CvTextInput/CvTextInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div
:class="[
'cv-text-input',
`${carbonPrefix}--form-item`,
`${carbonPrefix}--text-input-wrapper`,
]"
>
<label :class="[`${carbonPrefix}--label`]">
{{ label }}
</label>
</div>
</template>

<script setup>
import { carbonPrefix } from '../../global/settings';
const props = defineProps({
label: String,
});
</script>
15 changes: 15 additions & 0 deletions src/components/CvTextInput/__tests__/CvTextInput.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { render } from '@testing-library/vue';
import CvTextInput from '..';

describe('CvTextInput', () => {
it("renders label when 'label' prop is passed", () => {
const dummyLabel = 'Dummy Label';
const { getByText } = render(CvTextInput, {
props: { label: dummyLabel },
});

const label = getByText(dummyLabel);
expect(label.tagName).toBe('LABEL');
expect(label.textContent).toBe(dummyLabel);
});
});
4 changes: 4 additions & 0 deletions src/components/CvTextInput/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import CvTextInput from './CvTextInput.vue';

export { CvTextInput };
export default CvTextInput;

0 comments on commit ed2d603

Please sign in to comment.