Skip to content

Commit

Permalink
feat: rajoute les tests historiquement exclus
Browse files Browse the repository at this point in the history
  • Loading branch information
Shamzic committed Jan 31, 2025
1 parent 913ed1e commit cfe3d58
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 10 deletions.
66 changes: 60 additions & 6 deletions tests/unit/components/ressource/types.spec.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,92 @@
import { expect } from "vitest"
import { mount } from "@vue/test-utils"
import { createPinia, setActivePinia } from "pinia"
import { createRouter, createMemoryHistory } from "vue-router"
import Types from "@/components/ressource/types.vue"

describe("types.vue", () => {
it("sort ressource types following multiple criterias", () => {
const router = createRouter({
history: createMemoryHistory(),
routes: [],
})
const pinia = createPinia()
const mockStore = {
situation: {},
dates: {
twelveMonthsAgo: { label: "test" },
},
simulation: {
answers: {
all: [],
},
},
getAllSteps: [],
answer: () => {},
}

const mountComponent = () => {
return mount(Types, {
props: {
individu: {},
},
global: {
mocks: {
$route: { params: { id: "test" } },
$push: () => {},
},
plugins: [pinia, router],
provide: {
store: mockStore,
},
},
})
}

beforeEach(() => {
setActivePinia(pinia)
})

describe("sort method", () => {
const categories = [
{ label: "Stage" },
{ positionInList: 1, label: "Salaire 1" },
{ positionInList: 2, label: "Salaire 2" },
{ label: "Prime" },
]
const result = [

const expectedResult = [
{ positionInList: 1, label: "Salaire 1" },
{ positionInList: 2, label: "Salaire 2" },
{ label: "Prime" },
{ label: "Stage" },
]
expect(Types.default.methods.sort(categories)).toEqual(result)

it("should sort ressource types following multiple criterias", () => {
const wrapper = mountComponent()
expect(wrapper.vm.sort(categories)).toEqual(expectedResult)
})
})

it("group ressource by types", () => {
describe("groupTypes method", () => {
const categories = [
{ label: "Salaire", category: "Revenus" },
{ label: "Revenus de stage", category: "Revenus" },
{ label: "APL", category: "Allocations" },
{ label: "Bourse", category: "Autre" },
]
const result = {

const expectedResult = {
Autre: [{ label: "Bourse", category: "Autre" }],
Allocations: [{ label: "APL", category: "Allocations" }],
Revenus: [
{ label: "Salaire", category: "Revenus" },
{ label: "Revenus de stage", category: "Revenus" },
],
}
expect(Types.default.methods.groupTypes(categories)).toEqual(result)

it("should group resources by their types", () => {
const wrapper = mountComponent()
expect(wrapper.vm.groupTypes(categories)).toEqual(expectedResult)
})
})
})
4 changes: 0 additions & 4 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ export default defineConfig({
globals: true,
environment: "jsdom",
include: ["tests/**/*.spec.ts"],
exclude: [
"tests/unit/views/fiscales.spec.ts",
"tests/unit/components/ressource/types.spec.ts",
],
setupFiles: [],
coverage: {
provider: "v8",
Expand Down

0 comments on commit cfe3d58

Please sign in to comment.