Skip to content

Commit

Permalink
feat: port CvCheckboxSkeleton to Vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
OlkaB committed Jul 18, 2023
1 parent 1a02db8 commit f7b10cb
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/components/CvCheckbox/CvCheckbox.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
storyParametersObject,
} from '../../global/storybook-utils';

import { CvCheckbox } from '.';
import { CvCheckbox, CvCheckboxSkeleton } from '.';
import { action } from '@storybook/addon-actions';
import { props as propsCvCheck } from '../../use/cvCheck';
import { ref } from 'vue';
Expand Down Expand Up @@ -109,3 +109,15 @@ vModel.parameters = storyParametersObject(
templateVModel,
vModel.args
);

const templateSkeleton = `<cv-checkbox-skeleton></cv-checkbox-skeleton>`;

Check warning on line 114 in src/components/CvCheckbox/CvCheckbox.stories.js

View workflow job for this annotation

GitHub Actions / lint

'args' is defined but never used
const TemplateSkeleton = args => {
return {
components: { CvCheckboxSkeleton },
setup: () => {},
template: templateSkeleton,
};
};

export const Skeleton = TemplateSkeleton.bind({});
16 changes: 16 additions & 0 deletions src/components/CvCheckbox/CvCheckboxSkeleton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div
class="cv-checkbox"
:class="`${carbonPrefix}--form-item ${carbonPrefix}--checkbox-wrapper`"
>
<label :class="`${carbonPrefix}--checkbox-label ${carbonPrefix}--skeleton`">
<span
:class="`${carbonPrefix}--checkbox-label-text ${carbonPrefix}--skeleton`"
></span>
</label>
</div>
</template>

<script setup>
import { carbonPrefix } from '../../global/settings';
</script>
27 changes: 27 additions & 0 deletions src/components/CvCheckbox/__tests__/CvCheckboxSkeleton.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { shallowMount } from '@vue/test-utils';
import { carbonPrefix } from '../../../global/settings';
import CvCheckboxSkeleton from '../CvCheckboxSkeleton.vue';

describe('CvCheckboxSkeleton', () => {
it('renders checkbox skeleton', async () => {
const wrapper = shallowMount(CvCheckboxSkeleton);

expect(wrapper.html()).toMatchSnapshot();
});

it('renders checkbox skeleton with required visual elements', () => {
const wrapper = shallowMount(CvCheckboxSkeleton);

const skeletonWrapper = wrapper.find('.cv-checkbox');
const skeletonLabel = skeletonWrapper.find(
`.${carbonPrefix}--checkbox-label`
);
const skeletonText = skeletonWrapper.find(
`.${carbonPrefix}--checkbox-label-text`
);
const expectedSkeletonClass = `${carbonPrefix}--skeleton`;

expect(skeletonLabel.classes()).toContain(expectedSkeletonClass);
expect(skeletonText.classes()).toContain(expectedSkeletonClass);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CvCheckboxSkeleton renders checkbox skeleton 1`] = `<div class="cv-checkbox bx--form-item bx--checkbox-wrapper"><label class="bx--checkbox-label bx--skeleton"><span class="bx--checkbox-label-text bx--skeleton"></span></label></div>`;
3 changes: 2 additions & 1 deletion src/components/CvCheckbox/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CvCheckbox from './CvCheckbox.vue';
export { CvCheckbox };
import CvCheckboxSkeleton from './CvCheckboxSkeleton.vue';
export { CvCheckbox, CvCheckboxSkeleton };
export default CvCheckbox;

0 comments on commit f7b10cb

Please sign in to comment.