-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
42,443 additions
and
18,945 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export default { | ||
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel', | ||
testEnvironment: "jsdom", | ||
transform: { | ||
"^.+\\.vue$": "@vue/vue3-jest", | ||
"^.+\\js$": "babel-jest", | ||
}, | ||
moduleFileExtensions: ["vue", "js"], | ||
moduleNameMapper: { | ||
"^@/(.*)$": "<rootDir>/src/$1", | ||
}, | ||
coveragePathIgnorePatterns: ["/node_modules/", "/tests/"], | ||
coverageReporters: ["text", "json-summary"], | ||
// Fix in order for vue-test-utils to work with Jest 29 | ||
// https://test-utils.vuejs.org/migration/#test-runners-upgrade-notes | ||
testEnvironmentOptions: { | ||
customExportConditions: ["node", "node-addons"], | ||
}, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import ActionBar from "../../ActionBar.vue"; | ||
import { flushPromises, mount } from "@vue/test-utils"; | ||
import { test, expect, describe, beforeEach, vi } from "vitest"; | ||
import { createPinia, defineStore, setActivePinia } from "pinia"; | ||
import { createTestingPinia } from "@pinia/testing"; | ||
import useMoviesStore from "@/store/moviesStore"; | ||
import useFilterButtonsStore from "@/store/filterButtonsStore"; | ||
|
||
const wrapper = mount(ActionBar, { | ||
global: { | ||
plugins: [ | ||
createTestingPinia({ | ||
stubActions: false, | ||
createSpy: vi.fn, | ||
}) | ||
] | ||
} | ||
}); | ||
|
||
test("Component should mount", () => { | ||
|
||
expect(wrapper).toBeTruthy(); | ||
}); | ||
|
||
test("Component should search for The Lord of the Rings movies", async () => { | ||
|
||
const movieStore = useMoviesStore(); | ||
await wrapper.find('#search-input').setValue("The Lord of the Rings"); | ||
await wrapper.find('#search-button').trigger("click"); | ||
|
||
expect(wrapper.find('#search-input').element.value).toBe("The Lord of the Rings"); | ||
expect(movieStore.movies).toHaveLength(3); | ||
}); | ||
|
||
test("Component should search for Pulp Fiction", async () => { | ||
|
||
const moviesStore = useMoviesStore(); | ||
await wrapper.find("#search-input").setValue("Pulp Fiction"); | ||
await wrapper.find("#search-button").trigger("click"); | ||
|
||
expect(moviesStore.movies).toHaveLength(1); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { mount } from "@vue/test-utils"; | ||
import Banner from "../../Banner.vue"; | ||
import { test, expect, vi } from "vitest"; | ||
import { createTestingPinia } from "@pinia/testing"; | ||
|
||
const wrapper = mount(Banner, { | ||
global: { | ||
plugins: [ | ||
createTestingPinia({ | ||
stubActions: false, | ||
createSpy: vi.fn, | ||
}) | ||
] | ||
} | ||
}); | ||
|
||
test("Component should mount", () => { | ||
expect(wrapper).toBeTruthy(); | ||
}); | ||
|
||
test("Banner should contain title FIND YOUR MOVIE", () => { | ||
expect(wrapper.find('#banner-title').text()).toBe("FIND YOUR MOVIE"); | ||
}); | ||
|
||
test("Component should contain action bar and filter", () => { | ||
expect(wrapper.find("#banner-action-bar").exists()).toBeTruthy(); | ||
expect(wrapper.find("#banner-filter").exists()).toBeTruthy(); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { mount } from "@vue/test-utils"; | ||
import Button from "../../Button.vue"; | ||
import { test, expect } from "vitest"; | ||
|
||
|
||
test("renders a button", () => { | ||
const wrapper = mount(Button); | ||
|
||
expect(wrapper.get('button').text()).toBe(""); | ||
}); | ||
|
||
test("button should have title SEARCH", () => { | ||
const wrapper = mount(Button, { | ||
props: { | ||
title: "SEARCH", | ||
} | ||
}); | ||
|
||
expect(wrapper.get("#button").text()).toBe("SEARCH"); | ||
}); | ||
|
||
test("button should have title SORT and class 'button-primary' ", () => { | ||
const wrapper = mount(Button, { | ||
props: { | ||
title: "SORT", | ||
type: "primary" | ||
} | ||
}); | ||
|
||
expect(wrapper.get("#button").text()).toBe("SORT"); | ||
expect(wrapper.get("#button").classes()).toContain("button-primary"); | ||
}); | ||
|
||
test("button should have title SORT and shouldn't have class 'button-primary'", () => { | ||
const wrapper = mount(Button, { | ||
props: { | ||
title: "SORT", | ||
type: "secondary" | ||
} | ||
}); | ||
|
||
expect(wrapper.get("#button").text()).toBe("SORT"); | ||
expect(wrapper.get("#button").classes).not.toContain("button-primary"); | ||
}); |
Oops, something went wrong.