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
48a609dc
Commit
48a609dc
authored
May 04, 2021
by
Keith Becker
Browse files
clean up from merge
parent
f4727ea6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
87 deletions
+5
-87
src/utils/course.js
src/utils/course.js
+0
-1
tests/unit/views/TrainingDetails.spec.js
tests/unit/views/TrainingDetails.spec.js
+5
-86
No files found.
src/utils/course.js
View file @
48a609dc
...
@@ -4,7 +4,6 @@ export const availableSeatsInCourse = (
...
@@ -4,7 +4,6 @@ export const availableSeatsInCourse = (
registrations
registrations
)
=>
{
)
=>
{
if
(
!
Number
.
isInteger
(
capacity
))
{
if
(
!
Number
.
isInteger
(
capacity
))
{
console
.
warn
(
"
capacity was not an integer so default course capacity is 0
"
);
return
0
;
return
0
;
}
}
if
(
Array
.
isArray
(
selectedMembers
))
{
if
(
Array
.
isArray
(
selectedMembers
))
{
...
...
tests/unit/views/TrainingDetails.spec.js
View file @
48a609dc
...
@@ -37,6 +37,11 @@ describe("TrainingDetails", () => {
...
@@ -37,6 +37,11 @@ describe("TrainingDetails", () => {
TrainingDetails
.
fetchData
=
jest
.
fn
();
TrainingDetails
.
fetchData
=
jest
.
fn
();
const
wrapper
=
shallowMount
(
TrainingDetails
,
{
const
wrapper
=
shallowMount
(
TrainingDetails
,
{
mocks
:
{
mocks
:
{
$route
:
{
params
:
{
trainingId
:
1
,
},
},
$store
:
{
$store
:
{
state
:
{
state
:
{
error
:
{},
error
:
{},
...
@@ -171,92 +176,6 @@ describe("TrainingDetails", () => {
...
@@ -171,92 +176,6 @@ describe("TrainingDetails", () => {
true
true
);
);
});
});
it
(
"
should add student
"
,
async
()
=>
{
TrainingService
.
getCourse
=
jest
.
fn
().
mockResolvedValue
(
mockCourse
);
TrainingService
.
getCourseRegistrationsById
=
jest
.
fn
()
.
mockResolvedValue
({
registrations
:
[]
});
TrainingService
.
addStudents
=
jest
.
fn
().
mockResolvedValue
([]);
const
wrapper
=
shallowMount
(
TrainingDetails
,
{
mocks
:
{
$store
:
{
state
:
{
error
:
{},
},
commit
:
jest
.
fn
(),
},
},
data
()
{
return
{
selectedUsers
:
[{
userId
:
1
},
{
userId
:
2
}],
listItems
:
[{
userId
:
1
},
{
userId
:
2
},
{
userId
:
3
}],
};
},
propsData
,
localVue
,
vuetify
,
});
await
flushPromises
();
wrapper
.
vm
.
$refs
.
userSelect
.
clear
=
jest
.
fn
();
await
wrapper
.
vm
.
addStudent
([{
id
:
1
}]);
expect
(
TrainingService
.
addStudents
).
toHaveBeenCalledTimes
(
1
);
});
it
(
"
addStudent should catch error
"
,
async
()
=>
{
console
.
error
=
jest
.
fn
();
// mock console.error when expecting error messages
TrainingService
.
getCourse
=
jest
.
fn
().
mockResolvedValue
(
mockCourse
);
TrainingService
.
addStudents
=
jest
.
fn
().
mockRejectedValue
(
"
error
"
);
const
wrapper
=
shallowMount
(
TrainingDetails
,
{
mocks
:
{
$store
:
{
state
:
{
error
:
{},
},
commit
:
jest
.
fn
(),
},
},
propsData
,
localVue
,
vuetify
,
});
wrapper
.
vm
.
$refs
.
userSelect
.
clear
=
jest
.
fn
();
await
wrapper
.
vm
.
addStudent
();
expect
(
wrapper
.
vm
.
$store
.
commit
).
toHaveBeenCalledWith
(
SET_ERROR_MESSAGE
,
"
error
"
);
});
it
(
"
should cancel add student
"
,
async
()
=>
{
TrainingService
.
getCourse
=
jest
.
fn
().
mockResolvedValue
(
mockCourse
);
TrainingService
.
getCourseRegistrationsById
=
jest
.
fn
()
.
mockResolvedValue
({
registrations
:
[]
});
const
wrapper
=
shallowMount
(
TrainingDetails
,
{
mocks
:
{
$store
:
{
state
:
{
error
:
{},
},
commit
:
jest
.
fn
(),
},
},
data
()
{
return
{
selectedUsers
:
[{
userId
:
1
},
{
userId
:
2
}],
listItems
:
[{
userId
:
1
},
{
userId
:
2
},
{
userId
:
3
}],
};
},
propsData
,
localVue
,
vuetify
,
});
await
flushPromises
();
wrapper
.
vm
.
$refs
.
userSelect
.
clear
=
jest
.
fn
();
wrapper
.
vm
.
cancelAddStudent
();
expect
(
wrapper
.
vm
.
$refs
.
userSelect
.
clear
).
toHaveBeenCalledTimes
(
1
);
});
it
(
"
should not show error by default
"
,
()
=>
{
it
(
"
should not show error by default
"
,
()
=>
{
TrainingService
.
getCourse
=
jest
.
fn
().
mockResolvedValue
(
mockCourse
);
TrainingService
.
getCourse
=
jest
.
fn
().
mockResolvedValue
(
mockCourse
);
// render the component
// render the component
...
...
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