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 85d3eb8
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 11 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-->
8 changes: 6 additions & 2 deletions packages/docs/docs/components/maz-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,19 @@ You can use MazTable and his child component to build a simple table and enjoy t
<script lang="ts" setup>
import MazTable from 'maz-ui/components/MazTable'
import MazTableRow from 'maz-ui/components/MazTable'
import MazTableCell from 'maz-ui/components/MazTable'
import MazTableRow from 'maz-ui/components/MazTableRow'
import MazTableCell from 'maz-ui/components/MazTableCell'
</script>
```

:::

## Advanced

You can also provide all your data, the table is auto-generated and you can use the features [listed on top](#key-features)

---

`v-model="{{selectedIds ?? 'undefined'}}"`
<br />
`v-model:search-query="{{searchQuery ?? 'undefined'}}"`
Expand Down
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
24 changes: 17 additions & 7 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 All @@ -29,7 +32,7 @@
>
<caption v-if="caption || $slots.caption">
<!--
@slot caption - replace caption
@slot caption - add caption on top or bottom of the table
-->
<slot name="caption">
{{ caption }}
Expand Down Expand Up @@ -75,10 +78,10 @@
-->
<slot name="header" :header="header" :label="header.label">
<!--
@slot header-label-{key} - replace column header label
@binding {Object} header - header data
@binding {String} label - header label
-->
@slot header-label-{key} - replace column header label
@binding {Object} header - header data
@binding {String} label - header label
-->
<slot :name="`header-label-${header.key}`" :header="header" :label="header.label">
{{ header.label }}
</slot>
Expand All @@ -97,6 +100,9 @@
</span>
</MazTableTitle>
<MazTableTitle v-if="$slots.actions" align="left" :class="`--${size}`">
<!--
@slot actions-header - replace text of actions header
-->
<slot name="actions-header"> Actions </slot>
</MazTableTitle>
</MazTableRow>
Expand Down Expand Up @@ -151,6 +157,9 @@
</slot>
</MazTableCell>
<MazTableCell v-if="$slots.actions">
<!--
@slot actions - will add actions column
-->
<slot name="actions"></slot>
</MazTableCell>
</MazTableRow>
Expand Down Expand Up @@ -262,6 +271,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 85d3eb8

Please sign in to comment.