UNCLASSIFIED
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Platform One
P
Party Bus
Launchboard
launchboard-fe
Commits
a674e799
Commit
a674e799
authored
Feb 24, 2021
by
graham.smith
Browse files
more unit tests and refactoring
parent
10a7f324
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
66 additions
and
52 deletions
+66
-52
src/components/AddCourse.vue
src/components/AddCourse.vue
+2
-2
src/components/UserSelect.vue
src/components/UserSelect.vue
+0
-1
src/views/TrainingDetails.vue
src/views/TrainingDetails.vue
+0
-4
src/views/super-admin/Training.vue
src/views/super-admin/Training.vue
+5
-5
tests/unit/App.spec.js
tests/unit/App.spec.js
+2
-0
tests/unit/components/AddCourse.spec.js
tests/unit/components/AddCourse.spec.js
+6
-6
tests/unit/components/CurriculumSchedule.spec.js
tests/unit/components/CurriculumSchedule.spec.js
+1
-0
tests/unit/components/NavBar.spec.js
tests/unit/components/NavBar.spec.js
+1
-0
tests/unit/components/SystemStatusSummary.spec.js
tests/unit/components/SystemStatusSummary.spec.js
+0
-2
tests/unit/components/UserSelect.spec.js
tests/unit/components/UserSelect.spec.js
+6
-2
tests/unit/store/modules/userPreferences.spec.js
tests/unit/store/modules/userPreferences.spec.js
+1
-0
tests/unit/views/TrainingDetails.spec.js
tests/unit/views/TrainingDetails.spec.js
+23
-13
tests/unit/views/super-admin/Personnel.spec.js
tests/unit/views/super-admin/Personnel.spec.js
+13
-15
tests/unit/views/super-admin/Training.spec.js
tests/unit/views/super-admin/Training.spec.js
+6
-2
No files found.
src/components/AddC
lass
.vue
→
src/components/AddC
ourse
.vue
View file @
a674e799
...
@@ -158,7 +158,7 @@
...
@@ -158,7 +158,7 @@
:disabled=
"!valid"
:disabled=
"!valid"
color=
"primary"
color=
"primary"
:loading=
"addBusy"
:loading=
"addBusy"
@
click=
"addC
lass
()"
@
click=
"addC
ourse
()"
>
>
Add Class
Add Class
</v-btn>
</v-btn>
...
@@ -197,7 +197,7 @@ export default {
...
@@ -197,7 +197,7 @@ export default {
this
.
$emit
(
"
cancel
"
);
this
.
$emit
(
"
cancel
"
);
this
.
init
();
this
.
init
();
},
},
addC
lass
()
{
addC
ourse
()
{
this
.
$emit
(
"
add
"
,
this
.
toAdd
);
this
.
$emit
(
"
add
"
,
this
.
toAdd
);
this
.
init
();
this
.
init
();
},
},
...
...
src/components/UserSelect.vue
View file @
a674e799
...
@@ -148,7 +148,6 @@ export default {
...
@@ -148,7 +148,6 @@ export default {
},
},
async
query
(
val
)
{
async
query
(
val
)
{
try
{
try
{
console
.
log
(
"
val:
"
,
val
);
const
newItems
=
await
UserService
.
search
({
q
:
val
});
const
newItems
=
await
UserService
.
search
({
q
:
val
});
if
(
this
.
model
)
{
if
(
this
.
model
)
{
if
(
Array
.
isArray
(
this
.
model
))
{
if
(
Array
.
isArray
(
this
.
model
))
{
...
...
src/views/TrainingDetails.vue
View file @
a674e799
...
@@ -363,11 +363,9 @@ export default {
...
@@ -363,11 +363,9 @@ export default {
}),
}),
computed
:
{
computed
:
{
getSelectedPocs
()
{
getSelectedPocs
()
{
console
.
log
(
this
.
selectedPocs
);
return
this
.
selectedPocs
;
return
this
.
selectedPocs
;
},
},
getSelectedStudents
()
{
getSelectedStudents
()
{
console
.
log
(
this
.
selectedStudents
);
return
this
.
selectedStudents
;
return
this
.
selectedStudents
;
},
},
},
},
...
@@ -376,12 +374,10 @@ export default {
...
@@ -376,12 +374,10 @@ export default {
this
.
trainingCourse
=
await
TrainingService
.
getCourse
(
this
.
trainingCourse
=
await
TrainingService
.
getCourse
(
this
.
$route
.
params
.
trainingId
this
.
$route
.
params
.
trainingId
);
);
console
.
log
(
this
.
trainingCourse
);
this
.
loading
=
false
;
this
.
loading
=
false
;
},
},
methods
:
{
methods
:
{
removeSelectedStudent
()
{
removeSelectedStudent
()
{
console
.
log
(
this
.
getSelectedStudents
);
const
removeStudentIds
=
this
.
getSelectedStudents
.
map
(
const
removeStudentIds
=
this
.
getSelectedStudents
.
map
(
(
student
)
=>
student
.
id
(
student
)
=>
student
.
id
);
);
...
...
src/views/super-admin/Training.vue
View file @
a674e799
...
@@ -109,10 +109,10 @@
...
@@ -109,10 +109,10 @@
</v-row>
</v-row>
</v-container>
</v-container>
<AddC
lass
<AddC
ourse
v-if=
"state.isAdding"
v-if=
"state.isAdding"
@
cancel=
"state.isAdding = false"
@
cancel=
"state.isAdding = false"
@
add=
"addC
lass
"
@
add=
"addC
ourse
"
:add-busy=
"state.isAddingBusy"
:add-busy=
"state.isAddingBusy"
/>
/>
</template>
</template>
...
@@ -269,7 +269,7 @@
...
@@ -269,7 +269,7 @@
<
script
>
<
script
>
import
Vue
from
"
vue
"
;
import
Vue
from
"
vue
"
;
import
TrainingService
from
"
@/api/services/training
"
;
import
TrainingService
from
"
@/api/services/training
"
;
import
AddC
lass
from
"
@/components/AddC
lass
"
;
import
AddC
ourse
from
"
@/components/AddC
ourse
"
;
import
{
defaultSnackbarTimeout
,
debounceTimeout
}
from
"
@/config/config
"
;
import
{
defaultSnackbarTimeout
,
debounceTimeout
}
from
"
@/config/config
"
;
import
{
trainingTypes
}
from
"
@/config/reference-data
"
;
import
{
trainingTypes
}
from
"
@/config/reference-data
"
;
import
isEqual
from
"
lodash/isEqual
"
;
import
isEqual
from
"
lodash/isEqual
"
;
...
@@ -283,7 +283,7 @@ import { createDefaultPaginationParams } from "@/utils/tableHelpers";
...
@@ -283,7 +283,7 @@ import { createDefaultPaginationParams } from "@/utils/tableHelpers";
export
default
{
export
default
{
components
:
{
components
:
{
AddC
lass
,
AddC
ourse
,
},
},
data
:
()
=>
({
data
:
()
=>
({
initialLoad
:
true
,
initialLoad
:
true
,
...
@@ -387,7 +387,7 @@ export default {
...
@@ -387,7 +387,7 @@ export default {
}
}
},
},
async
addC
lass
(
toAdd
)
{
async
addC
ourse
(
toAdd
)
{
this
.
state
.
isAddingBusy
=
true
;
this
.
state
.
isAddingBusy
=
true
;
toAdd
.
seats
=
{
toAdd
.
seats
=
{
...
...
tests/unit/App.spec.js
View file @
a674e799
...
@@ -38,6 +38,7 @@ describe("Launchboard InitialLoadingApp", () => {
...
@@ -38,6 +38,7 @@ describe("Launchboard InitialLoadingApp", () => {
},
},
},
},
},
},
stubs
:
[
"
router-view
"
],
localVue
,
localVue
,
vuetify
,
vuetify
,
});
});
...
@@ -58,6 +59,7 @@ describe("Launchboard InitialLoadingApp", () => {
...
@@ -58,6 +59,7 @@ describe("Launchboard InitialLoadingApp", () => {
},
},
},
},
},
},
stubs
:
[
"
router-view
"
],
localVue
,
localVue
,
vuetify
,
vuetify
,
});
});
...
...
tests/unit/components/AddC
lass
.spec.js
→
tests/unit/components/AddC
ourse
.spec.js
View file @
a674e799
import
{
shallowMount
}
from
"
@vue/test-utils
"
;
import
{
shallowMount
}
from
"
@vue/test-utils
"
;
import
AddC
lass
from
"
@/components/AddC
lass
"
;
import
AddC
ourse
from
"
@/components/AddC
ourse
"
;
describe
(
"
LaunchboardAdmin
"
,
()
=>
{
describe
(
"
AddCourse
"
,
()
=>
{
it
(
"
should emit cancel
"
,
async
()
=>
{
it
(
"
should emit cancel
"
,
async
()
=>
{
const
wrapper
=
shallowMount
(
AddC
lass
);
const
wrapper
=
shallowMount
(
AddC
ourse
);
wrapper
.
vm
.
cancel
();
wrapper
.
vm
.
cancel
();
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
().
cancel
).
toBeTruthy
();
expect
(
wrapper
.
emitted
().
cancel
).
toBeTruthy
();
});
});
it
(
"
should emit add
"
,
async
()
=>
{
it
(
"
should emit add
"
,
async
()
=>
{
const
wrapper
=
shallowMount
(
AddC
lass
);
const
wrapper
=
shallowMount
(
AddC
ourse
);
wrapper
.
vm
.
addC
lass
();
wrapper
.
vm
.
addC
ourse
();
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
().
add
).
toBeTruthy
();
expect
(
wrapper
.
emitted
().
add
).
toBeTruthy
();
expect
(
wrapper
.
emitted
().
add
[
0
]).
toEqual
([
wrapper
.
vm
.
toAdd
]);
expect
(
wrapper
.
emitted
().
add
[
0
]).
toEqual
([
wrapper
.
vm
.
toAdd
]);
});
});
describe
(
"
input validation rules
"
,
()
=>
{
describe
(
"
input validation rules
"
,
()
=>
{
const
wrapper
=
shallowMount
(
AddC
lass
);
const
wrapper
=
shallowMount
(
AddC
ourse
);
it
(
"
should check required
"
,
()
=>
{
it
(
"
should check required
"
,
()
=>
{
expect
(
wrapper
.
vm
.
inputRules
.
required
()).
toEqual
(
"
* Required
"
);
expect
(
wrapper
.
vm
.
inputRules
.
required
()).
toEqual
(
"
* Required
"
);
expect
(
wrapper
.
vm
.
inputRules
.
required
(
"
aaa
"
)).
toEqual
(
true
);
expect
(
wrapper
.
vm
.
inputRules
.
required
(
"
aaa
"
)).
toEqual
(
true
);
...
...
tests/unit/components/CurriculumSchedule.spec.js
View file @
a674e799
...
@@ -18,6 +18,7 @@ describe("CurriculumSchedule", () => {
...
@@ -18,6 +18,7 @@ describe("CurriculumSchedule", () => {
});
});
it
(
"
should set loading to false on error
"
,
async
()
=>
{
it
(
"
should set loading to false on error
"
,
async
()
=>
{
console
.
error
=
jest
.
fn
();
// mock console.error when expecting error messages
ScheduleService
.
getScheduleForUser
=
jest
ScheduleService
.
getScheduleForUser
=
jest
.
fn
()
.
fn
()
.
mockRejectedValue
(
"
mock error
"
);
.
mockRejectedValue
(
"
mock error
"
);
...
...
tests/unit/components/NavBar.spec.js
View file @
a674e799
...
@@ -27,6 +27,7 @@ test("NavBar", () => {
...
@@ -27,6 +27,7 @@ test("NavBar", () => {
},
},
},
},
},
},
stubs
:
[
"
router-link
"
],
localVue
,
localVue
,
vuetify
,
vuetify
,
});
});
...
...
tests/unit/components/SystemStatusSummary.spec.js
View file @
a674e799
...
@@ -21,8 +21,6 @@ test("SystemStatusSummary", () => {
...
@@ -21,8 +21,6 @@ test("SystemStatusSummary", () => {
vuetify
,
vuetify
,
});
});
wrapper
.
vm
.
tempAlert
();
// assert the component loads without error
// assert the component loads without error
expect
(
wrapper
.
find
(
"
.error
"
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
"
.error
"
).
exists
()).
toBe
(
false
);
});
});
tests/unit/components/UserSelect.spec.js
View file @
a674e799
...
@@ -135,9 +135,13 @@ describe("LaunchboardAdmin", () => {
...
@@ -135,9 +135,13 @@ describe("LaunchboardAdmin", () => {
wrapper
.
vm
.
model
=
null
;
wrapper
.
vm
.
model
=
null
;
await
wrapper
.
vm
.
query
();
await
wrapper
.
vm
.
query
();
expect
(
wrapper
.
vm
.
items
).
toEqual
([
"
a
"
]);
expect
(
wrapper
.
vm
.
items
).
toEqual
([
"
a
"
]);
});
// error
it
(
"
should set items to empty array on error
"
,
async
()
=>
{
console
.
error
=
jest
.
fn
();
// mock console.error when expecting error messages
UserService
.
search
=
jest
.
fn
().
mockRejectedValue
(
"
mock error
"
);
UserService
.
search
=
jest
.
fn
().
mockRejectedValue
(
"
mock error
"
);
const
wrapper
=
mount
(
UserSelect
,
{
vuetify
,
});
await
wrapper
.
vm
.
query
();
await
wrapper
.
vm
.
query
();
expect
(
wrapper
.
vm
.
items
).
toEqual
([]);
expect
(
wrapper
.
vm
.
items
).
toEqual
([]);
});
});
...
...
tests/unit/store/modules/userPreferences.spec.js
View file @
a674e799
...
@@ -46,6 +46,7 @@ describe("initial-load store", () => {
...
@@ -46,6 +46,7 @@ describe("initial-load store", () => {
);
);
});
});
it
(
"
should fail and throw an error
"
,
async
()
=>
{
it
(
"
should fail and throw an error
"
,
async
()
=>
{
console
.
error
=
jest
.
fn
();
// mock console.error when expecting error messages
const
mockUserResponse
=
"
mock fail
"
;
const
mockUserResponse
=
"
mock fail
"
;
const
mockUserPreference
=
{
darkMode
:
true
};
const
mockUserPreference
=
{
darkMode
:
true
};
UserService
.
updateUserPreferences
=
jest
UserService
.
updateUserPreferences
=
jest
...
...
tests/unit/views/TrainingDetails.spec.js
View file @
a674e799
...
@@ -7,20 +7,30 @@ const vuetify = new Vuetify();
...
@@ -7,20 +7,30 @@ const vuetify = new Vuetify();
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
localVue
.
use
(
Vuex
);
test
(
"
TrainingDetails
"
,
()
=>
{
describe
(
"
TrainingDetails
"
,
()
=>
{
// render the component
const
$route
=
{
const
wrapper
=
shallowMount
(
TrainingDetails
,
{
params
:
{
mocks
:
{
trainingId
:
42
,
$store
:
{
},
state
:
{
};
error
:
{},
it
(
"
should not show error by default
"
,
()
=>
{
// render the component
const
wrapper
=
shallowMount
(
TrainingDetails
,
{
mocks
:
{
$route
,
$store
:
{
state
:
{
error
:
{},
},
},
},
},
},
}
,
stubs
:
[
"
router-link
"
]
,
localVue
,
localVue
,
vuetify
,
vuetify
,
});
});
// assert the component loads without error
// assert the component loads without error
expect
(
wrapper
.
find
(
"
.error
"
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
"
.error
"
).
exists
()).
toBe
(
false
);
});
});
});
tests/unit/views/super-admin/Personnel.spec.js
View file @
a674e799
...
@@ -31,7 +31,6 @@ describe("LaunchboardAdmin", () => {
...
@@ -31,7 +31,6 @@ describe("LaunchboardAdmin", () => {
},
},
});
});
UserService
.
updateUserPersonnelType
=
jest
.
fn
(()
=>
null
);
UserService
.
updateUserPersonnelType
=
jest
.
fn
(()
=>
null
);
window
.
alert
=
jest
.
fn
();
wrapper
.
vm
.
$refs
.
userSelect
=
{
wrapper
.
vm
.
$refs
.
userSelect
=
{
clear
:
jest
.
fn
(),
clear
:
jest
.
fn
(),
};
};
...
@@ -104,21 +103,17 @@ describe("LaunchboardAdmin", () => {
...
@@ -104,21 +103,17 @@ describe("LaunchboardAdmin", () => {
// });
// });
it
(
"
should get all list items
"
,
async
()
=>
{
it
(
"
should get all list items
"
,
async
()
=>
{
const
wrapper
=
shallowMount
(
Personnel
,
{
const
wrapper
=
shallowMount
(
Personnel
);
data
()
{
return
{
personnel
:
{
types
:
{
executiveLeadership
:
"
Executive Leadership
"
,
pm
:
"
PM
"
,
businessOps
:
"
Business Ops
"
,
instructor
:
"
Instructor
"
,
},
},
};
},
});
wrapper
.
vm
.
personnel
=
{
userSelect
:
{},
types
:
{
executiveLeadership
:
"
Executive Leadership
"
,
pm
:
"
PM
"
,
businessOps
:
"
Business Ops
"
,
instructor
:
"
Instructor
"
,
},
};
wrapper
.
vm
.
$refs
.
personnel
.
getPersonnelListItems
=
jest
.
fn
(()
=>
{
wrapper
.
vm
.
$refs
.
personnel
.
getPersonnelListItems
=
jest
.
fn
(()
=>
{
return
[{
personnelType
:
"
Executive Leadership
"
}];
return
[{
personnelType
:
"
Executive Leadership
"
}];
});
});
...
@@ -172,6 +167,9 @@ describe("LaunchboardAdmin", () => {
...
@@ -172,6 +167,9 @@ describe("LaunchboardAdmin", () => {
},
},
});
});
wrapper
.
setData
({
filterSearchValue
:
"
test
"
,
filterSelectedValue
:
"
test
"
});
wrapper
.
setData
({
filterSearchValue
:
"
test
"
,
filterSelectedValue
:
"
test
"
});
wrapper
.
vm
.
$refs
.
personnel
=
{
fetchData
:
jest
.
fn
(),
};
wrapper
.
vm
.
getAllListItems
=
jest
.
fn
(()
=>
{
wrapper
.
vm
.
getAllListItems
=
jest
.
fn
(()
=>
{
return
[
return
[
...
...
tests/unit/views/super-admin/Training.spec.js
View file @
a674e799
...
@@ -4,6 +4,10 @@ import TrainingService from "@/api/services/training";
...
@@ -4,6 +4,10 @@ import TrainingService from "@/api/services/training";
describe
(
"
Training
"
,
()
=>
{
describe
(
"
Training
"
,
()
=>
{
const
mockCoursesResult
=
{
courses
:
[],
meta
:
{
total
:
0
}
};
const
mockCoursesResult
=
{
courses
:
[],
meta
:
{
total
:
0
}
};
afterEach
(()
=>
{
jest
.
restoreAllMocks
();
});
it
(
"
should debounce getCourses
"
,
async
()
=>
{
it
(
"
should debounce getCourses
"
,
async
()
=>
{
TrainingService
.
getCourses
=
jest
.
fn
().
mockResolvedValue
(
mockCoursesResult
);
TrainingService
.
getCourses
=
jest
.
fn
().
mockResolvedValue
(
mockCoursesResult
);
...
@@ -50,7 +54,7 @@ describe("Training", () => {
...
@@ -50,7 +54,7 @@ describe("Training", () => {
//
//
// const wrapper = shallowMount(Training);
// const wrapper = shallowMount(Training);
// const mockClass = { name: "mock class", totalSeats: 55 };
// const mockClass = { name: "mock class", totalSeats: 55 };
// await wrapper.vm.addC
lass
(mockClass);
// await wrapper.vm.addC
ourse
(mockClass);
//
//
// expect(TrainingService.addCourse).toHaveBeenCalledTimes(1);
// expect(TrainingService.addCourse).toHaveBeenCalledTimes(1);
// expect(TrainingService.addCourse).toHaveBeenCalledWith(mockClass);
// expect(TrainingService.addCourse).toHaveBeenCalledWith(mockClass);
...
@@ -59,7 +63,7 @@ describe("Training", () => {
...
@@ -59,7 +63,7 @@ describe("Training", () => {
//
//
// // error state
// // error state
// TrainingService.addCourse = jest.fn().mockRejectedValue("mock error");
// TrainingService.addCourse = jest.fn().mockRejectedValue("mock error");
// await wrapper.vm.addC
lass
(mockClass);
// await wrapper.vm.addC
ourse
(mockClass);
// expect(wrapper.vm.state.isAddingBusy).toEqual(false);
// expect(wrapper.vm.state.isAddingBusy).toEqual(false);
// expect(wrapper.vm.state.isAdding).toEqual(false);
// expect(wrapper.vm.state.isAdding).toEqual(false);
// });
// });
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment