Skip to content

Commit

Permalink
test(maz-ui): maz-loading-bar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisMazel committed Dec 24, 2023
1 parent 151a13a commit 50c2b70
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/docs/docs/.vitepress/configs/components.mts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const components = {
{ text: 'MazGallery', link: '/components/maz-gallery' },
{ text: 'MazIcon', link: '/components/maz-icon' },
{ text: 'MazLazyImg', link: '/components/maz-lazy-img' },
{ text: 'MazLoadingBar', link: '/components/maz-loading-bar' },
{ text: 'MazPullToRefresh', link: '/components/maz-pull-to-refresh' },
{ text: 'MazStepper', link: '/components/maz-stepper' },
{ text: 'MazSpinner', link: '/components/maz-spinner' },
Expand Down
26 changes: 26 additions & 0 deletions packages/docs/docs/components/maz-loading-bar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: MazLoadingBar
description: MazLoadingBar is a standalone component
---

# {{ $frontmatter.title }}

{{ $frontmatter.description }}

<!--@include: ./../.vitepress/mixins/getting-started.md-->

## Basic usage

<MazLoadingBar color="secondary" />

```vue
<template>
<MazLoadingBar color="secondary" />
</template>
<script lang="ts" setup>
import MazLoadingBar from 'maz-ui/components/MazLoadingBar'
</script>
```

<!--@include: ./../.vitepress/generated-docs/maz-loading-bar.doc.md-->
3 changes: 2 additions & 1 deletion packages/lib/components/MazLoadingBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

<style lang="postcss" scoped>
.m-loading-bar {
@apply maz-relative maz-block maz-h-0.5 maz-w-full maz-overflow-hidden maz-bg-primary-alpha-20;
@apply maz-relative maz-block maz-w-full maz-overflow-hidden;
height: v-bind('height');
background-color: v-bind('colorCSVariables.alpha');
overflow: hidden;
Expand Down
8 changes: 6 additions & 2 deletions packages/lib/components/MazTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
:size="size"
:color="color"
:placeholder="searchPlaceholder"
left-icon="search"
/>
>
<template #left-icon>
<SearchIcon class="maz-text-lg" />
</template>
</MazInput>
</div>
</div>

Expand Down Expand Up @@ -262,6 +265,7 @@
watch,
onBeforeMount,
} from 'vue'
import SearchIcon from './../icons/magnifying-glass.svg'
import ArrowIcon from './../icons/arrow-up.svg'
import ChevronIcon from './../icons/chevron-left.svg'
import ChevronDoubleIcon from './../icons/chevron-double-left.svg'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`MazLoadingBar > renders correct HTML structure 1`] = `
"<div data-v-744a78bd="" class="m-loading-bar">
<div data-v-744a78bd=""></div>
</div>"
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`MazTable > should render the component 1`] = `
"<div data-v-ac035b54="" class="m-table">
<!--v-if-->
<table data-v-ac035b54="" class="">
<!--v-if-->
<thead data-v-ac035b54="">
<!--
@slot thead - content in thead element
-->
<maztablerow data-v-ac035b54="" no-hoverable="">
<!--v-if-->
<!--v-if-->
</maztablerow>
</thead>
<!--v-if-->
<tbody data-v-ac035b54="" class="">
<maztablerow data-v-ac035b54="">
<maztablecell data-v-ac035b54="" colspan="0">
<!--
@slot no-results - replace no results
-->
<p data-v-ac035b54="" class="maz-text-center maz-text-muted">
<!--
@slot no-results-text - replace no results test only
--> No results
</p>
</maztablecell>
</maztablerow>
</tbody>
</table>
<!--v-if-->
</div>"
`;
2 changes: 1 addition & 1 deletion packages/lib/tests/specs/components/maz-btn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { shallowMount } from '@vue/test-utils'

describe('MazBtn', () => {
test('renders the component elements and classes correctly', () => {
const wrapper = shallowMount(MazBtn)
const wrapper = shallowMount(MazBtn, { slots: { default: 'Button Text' } })

expect(wrapper.find('button').exists()).toBe(true)
expect(wrapper.find('.m-btn__icon-left').exists()).toBe(false)
Expand Down
10 changes: 10 additions & 0 deletions packages/lib/tests/specs/components/maz-loading-bar.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { mount } from '@vue/test-utils'
import MazLoadingBar from '@components/MazLoadingBar.vue'

describe('MazLoadingBar', () => {
test('renders default color correctly', () => {
const wrapper = mount(MazLoadingBar)
expect(wrapper.vm.colorCSVariables.alpha).toBe('var(--maz-color-primary-alpha-20)')
expect(wrapper.vm.colorCSVariables.main).toBe('var(--maz-color-primary)')
})
})

0 comments on commit 50c2b70

Please sign in to comment.