-
Notifications
You must be signed in to change notification settings - Fork 45
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
1 parent
a2970a3
commit f780403
Showing
24 changed files
with
953 additions
and
1,872 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,78 +1,159 @@ | ||
import { mount as nativeMount, createLocalVue } from '@vue/test-utils'; | ||
import Vuetify from 'vuetify'; | ||
import { mount as nativeMount } from '@vue/test-utils'; | ||
import { vi } from 'vitest'; | ||
import { createVuetify } from 'vuetify'; | ||
import { createStore } from 'vuex'; | ||
import Vuex from 'vuex'; | ||
import * as components from 'vuetify/components'; | ||
import * as directives from 'vuetify/directives'; | ||
import HacknightWrapper from '../src/components/Dashboard/Hacknight/HacknightWrapper.vue'; | ||
import HacknightsParticipants from '../src/components/Dashboard/HacknightsParticipants/HacknightsParticipants.vue'; | ||
import DashboardHeader from '../src/components/Dashboard/Header/DashboardHeader.vue'; | ||
import ParticipantsSearch from '../src/components/Dashboard/Participants/ParticipantsSearch/ParticipantsSearch.vue'; | ||
import ParticipantsList from '../src/components/Dashboard/Participants/ParticipantsList.vue'; | ||
import ParticipantsChart from '../src/components/Dashboard/ParticipantsChart/ParticipantsChart.vue'; | ||
import DashboardMain from '../src/components/Dashboard/DashboardMain.vue'; | ||
import AboutUs from '../src/components/HomePage/AboutUs/AboutUs.vue'; | ||
import ContactUs from '../src/components/HomePage/ContactUs/ContactUs.vue'; | ||
import HomePageHeader from '../src/components/HomePage/Header/HomePageHeader.vue'; | ||
import JoinUs from '../src/components/HomePage/JoinUs/JoinUs.vue'; | ||
import OurProjects from '../src/components/HomePage/OurProjects/OurProjects.vue'; | ||
import ModalContent from '../src/components/HomePage/OurProjects/ModalContent/ModalContent.vue'; | ||
import PageFooter from '../src/components/HomePage/PageFooter/PageFooter.vue'; | ||
import SocialMedia from '../src/components/HomePage/SocialMedia/SocialMedia.vue'; | ||
import HomePage from '../src/components/HomePage/HomePage.vue'; | ||
import LoginForm from '../src/components/Login/LoginForm.vue'; | ||
|
||
const storeObject = { | ||
modules: { | ||
hacknight: { | ||
namespaced: true, | ||
getters: { | ||
getHacknights: jest.fn(() => []), | ||
getHacknight: jest.fn(() => ({ participants: [] })), | ||
getError: jest.fn() | ||
getHacknights: vi.fn(() => []), | ||
getHacknight: vi.fn(() => ({ participants: [] })), | ||
getError: vi.fn(), | ||
}, | ||
actions: { getHacknights: jest.fn() } | ||
actions: { getHacknights: vi.fn() }, | ||
}, | ||
participant: { | ||
namespaced: true, | ||
getters: { getParticipants: jest.fn(() => []), getError: jest.fn() }, | ||
actions: { getParticipants: jest.fn() } | ||
getters: { getParticipants: vi.fn(() => []), getError: vi.fn() }, | ||
actions: { getParticipants: vi.fn() }, | ||
}, | ||
auth: { | ||
namespaced: true, | ||
getters: { getError: jest.fn() } | ||
getters: { getError: vi.fn() }, | ||
}, | ||
contact: { | ||
namespaced: true, | ||
getters: { successfullySent: jest.fn(), msgErrorRaised: jest.fn() } | ||
} | ||
} | ||
getters: { successfullySent: vi.fn(), msgErrorRaised: vi.fn() }, | ||
}, | ||
}, | ||
}; | ||
|
||
// mount function from @vue/test-utils | ||
// needs this enhancement to render vuetify components correctly | ||
// source: https://vuetifyjs.com/en/getting-started/unit-testing/#mocking-vuetify | ||
|
||
export const getMountWithVuetify = () => { | ||
const localVue = createLocalVue(); | ||
const vuetify = new Vuetify(); | ||
const vuetify = createVuetify({ | ||
components, | ||
directives, | ||
}); | ||
|
||
return Component => { | ||
return nativeMount(Component, { localVue, vuetify }); | ||
}; | ||
return nativeMount({ | ||
props: {}, | ||
global: { | ||
components: { | ||
HacknightWrapper, | ||
HacknightsParticipants, | ||
DashboardHeader, | ||
ParticipantsSearch, | ||
ParticipantsList, | ||
ParticipantsChart, | ||
DashboardMain, | ||
AboutUs, | ||
ContactUs, | ||
HomePageHeader, | ||
JoinUs, | ||
OurProjects, | ||
ModalContent, | ||
PageFooter, | ||
SocialMedia, | ||
HomePage, | ||
LoginForm, | ||
}, | ||
plugins: [vuetify], | ||
}, | ||
}); | ||
}; | ||
|
||
// mount function from @vue/test-utils | ||
// needs this enhancement to render components using vuex correctly | ||
// source: https://vue-test-utils.vuejs.org/guides/using-with-vuex.html | ||
|
||
export const getMountWithVuex = () => { | ||
const localVue = createLocalVue(); | ||
localVue.use(Vuex); | ||
const store = createStore(storeObject); | ||
|
||
return Component => { | ||
const store = new Vuex.Store(storeObject); | ||
|
||
return nativeMount(Component, { store, localVue, stubs: ['apexchart'] }); | ||
}; | ||
return nativeMount({ | ||
props: {}, | ||
global: { | ||
components: { | ||
HacknightWrapper, | ||
HacknightsParticipants, | ||
DashboardHeader, | ||
ParticipantsSearch, | ||
ParticipantsList, | ||
ParticipantsChart, | ||
DashboardMain, | ||
AboutUs, | ||
ContactUs, | ||
HomePageHeader, | ||
JoinUs, | ||
OurProjects, | ||
ModalContent, | ||
PageFooter, | ||
SocialMedia, | ||
HomePage, | ||
LoginForm, | ||
}, | ||
plugins: [store], | ||
}, | ||
}); | ||
}; | ||
|
||
// Use this function if you need to test a component | ||
// that uses both Vuex and Vuetify | ||
|
||
export const getMountWithProviders = () => { | ||
const localVue = createLocalVue(); | ||
localVue.use(Vuex); | ||
const vuetify = new Vuetify(); | ||
|
||
return Component => { | ||
const store = new Vuex.Store(storeObject); | ||
const store = createStore(storeObject); | ||
const vuetify = createVuetify({ | ||
components, | ||
directives, | ||
}); | ||
|
||
return nativeMount(Component, { | ||
store, | ||
localVue, | ||
vuetify, | ||
stubs: ['apexchart'] | ||
}); | ||
}; | ||
return nativeMount({ | ||
props: {}, | ||
global: { | ||
components: { | ||
HacknightWrapper, | ||
HacknightsParticipants, | ||
DashboardHeader, | ||
ParticipantsSearch, | ||
ParticipantsList, | ||
ParticipantsChart, | ||
DashboardMain, | ||
AboutUs, | ||
ContactUs, | ||
HomePageHeader, | ||
JoinUs, | ||
OurProjects, | ||
ModalContent, | ||
PageFooter, | ||
SocialMedia, | ||
HomePage, | ||
LoginForm, | ||
}, | ||
plugins: [store, vuetify], | ||
}, | ||
}); | ||
}; |
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
5 changes: 3 additions & 2 deletions
5
frontend/src/components/Dashboard/Hacknight/HacknightWrapper.spec.js
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
5 changes: 3 additions & 2 deletions
5
frontend/src/components/Dashboard/HacknightsParticipants/HacknightsParticipants.spec.js
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
5 changes: 3 additions & 2 deletions
5
frontend/src/components/Dashboard/Header/DashboardHeader.spec.js
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
Oops, something went wrong.