Skip to content

Commit

Permalink
test(pages): home page should display a counter card (#2)
Browse files Browse the repository at this point in the history
* home page should display a counter card

* e.. t la pièce jointe !

* update imports

* rename import
  • Loading branch information
plecrx authored Jan 10, 2024
1 parent 456952b commit ad31b17
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 21 deletions.
8 changes: 0 additions & 8 deletions .vscode/extensions.json

This file was deleted.

Empty file removed public/.gitkeep
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia'
import { useCounterStore } from '~/stores/counter'
import {useCounterStore} from "@/stores/counter.ts";
defineProps<{ msg: string }>()
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from '~/App.vue'
import router from '~/router'
import App from '@/app.vue'
import router from '@/router'

const app = createApp(App)

Expand Down
2 changes: 1 addition & 1 deletion src/pages/HomePage.vue → src/pages/home-page.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import CounterCard from '@/components/counter-card.component.vue'
import CounterCard from '@/components/counter-card.vue'
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomePage from '~/pages/HomePage.vue'
import HomePage from '@/pages/home-page.vue'

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, it, expect } from 'vitest'

import { shallowMount } from '@vue/test-utils'
import CounterCard from '../../src/components/counter-card.component.vue'
import CounterCard from '../../src/components/counter-card.vue'
import { createPinia, setActivePinia } from 'pinia'

describe('CounterCard', () => {
it('renders properly', () => {
describe('Counter card', () => {
it('should render properly', () => {
setActivePinia(createPinia())
const wrapper = shallowMount(CounterCard, { props: { msg: 'Hello VueJS' } })

Expand Down
16 changes: 16 additions & 0 deletions tests/pages/home.page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { describe, it, expect } from 'vitest'

import { shallowMount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
import HomePage from '@/pages/home-page.vue'
import CounterCard from '@/components/counter-card.vue'

describe('Home page', () => {
it('should display a counter card', () => {
setActivePinia(createPinia())
const wrapper = shallowMount(HomePage)
const counterCard = wrapper.findComponent(CounterCard)

expect(counterCard.exists()).toBe(true)
})
})
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"~/*": ["src/*"],
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue, tests/**/*.ts"],
Expand Down
7 changes: 3 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite'
import type { UserConfig as VitestUserConfigInterface } from "vitest/config"
import vue from '@vitejs/plugin-vue'
import path from 'path'
import {fileURLToPath} from "url";

const vitestConfig: VitestUserConfigInterface = {
test: {
Expand All @@ -14,9 +14,8 @@ export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'~': path.resolve(__dirname, './src')
}
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
test: vitestConfig.test,
})

0 comments on commit ad31b17

Please sign in to comment.