-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rajoute les tests historiquement exclus
- Loading branch information
Showing
2 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters