-
Notifications
You must be signed in to change notification settings - Fork 4
/
DashboardHeader.spec.js
98 lines (81 loc) · 2.69 KB
/
DashboardHeader.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import 'axios'
import { shallowMount, createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import mockStore from 'mentor/store/__mocks__'
import DashboardHeader from 'mentor/DashboardHeader'
import DropDown from 'components/DropDown'
const localVue = createLocalVue()
localVue.use(Vuex)
describe("mentor/DashboardHeader.vue", () => {
let defaultWrapper
beforeEach(() => {
const defaultStore = mockStore.createMocks()
defaultWrapper = shallowMount(
DashboardHeader,
{
localVue,
store: new Vuex.Store({
modules: {
authenticated: {
namespaced: true,
state: defaultStore.state,
getters: defaultStore.getters,
mutations: defaultStore.mutations,
},
},
})
}
)
})
it("contains the two headers", () => {
expect(defaultWrapper.findAll('.dashboard-notices .grid__col-sm-6').length).toEqual(2)
})
it("contains the resources drop-down", () => {
const dropDown = defaultWrapper.find(DropDown)
expect(dropDown.exists()).toBe(true)
expect(dropDown.vm.label).toEqual("More Information")
})
it("displays the currentAccount's name", async () => {
defaultWrapper.vm.$store.commit('authenticated/htmlDataset', {
currentAccount: '{"data":{"attributes":{"name":"Saul Goodman"}}}'
})
await defaultWrapper.vm.$nextTick()
expect(defaultWrapper.find(
'.dashboard-notices .grid__col-sm-6:nth-child(2)'
).text()).toContain("Saul Goodman")
})
describe("when the RA has not provided an intro", () => {
it("displays the default left header", async () => {
defaultWrapper.setProps({
defaultTitle: "Mentor Dashboard",
resourceLinks: [
{
url: 'something',
text: 'something',
isSurveyLink: true
}
]
})
await defaultWrapper.vm.$nextTick()
expect(defaultWrapper.find(
'.dashboard-notices .grid__col-sm-6:first-child'
).text()).toContain("Mentor Dashboard")
expect(defaultWrapper.find(
'.dashboard-notices .grid__col-sm-6:first-child h1 small a'
).exists()).toBe(true)
})
})
describe("when the RA has provided an intro ", () => {
beforeEach(() => {
defaultWrapper.vm.$store.commit('authenticated/htmlDataset', {
regionalAmbassador: '{"data":{"attributes":{"name":"Jean Weiss","programName":"Technovation[MN]","hasProvidedIntro":true}}}'
})
})
it("displays the RA intro header", () => {
const text = defaultWrapper.find(
'.dashboard-notices .grid__col-sm-6:first-child'
).text()
expect(text).toContain("Technovation[MN]")
})
})
})