@@ -11,6 +11,18 @@ const {
11
11
const roleString = "test" ;
12
12
const initialResponse = "Fetching instructors..." ;
13
13
14
+ const Course = {
15
+ create : jest . fn ( ) ,
16
+ findOne : jest
17
+ . fn ( ( ) => true )
18
+ . mockImplementationOnce ( ( ) => false ) ,
19
+ destroy : jest . fn ( ) ,
20
+ } ;
21
+
22
+ const models = {
23
+ Course,
24
+ } ;
25
+
14
26
afterEach ( ( ) => {
15
27
jest . clearAllMocks ( ) ;
16
28
} ) ;
@@ -19,7 +31,7 @@ describe("slash instructors command", () => {
19
31
test ( "instructors command used outside course channels" , async ( ) => {
20
32
const client = studentInteractionWithoutOptions . client ;
21
33
const response = "Use the command in a course channel." ;
22
- await execute ( studentInteractionWithoutOptions , client ) ;
34
+ await execute ( studentInteractionWithoutOptions , client , models ) ;
23
35
expect ( sendEphemeral ) . toHaveBeenCalledTimes ( 1 ) ;
24
36
expect ( sendEphemeral ) . toHaveBeenCalledWith ( studentInteractionWithoutOptions , initialResponse ) ;
25
37
expect ( editErrorEphemeral ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -32,7 +44,7 @@ describe("slash instructors command", () => {
32
44
client . guild . roles . create ( { id : 5 , name : `${ roleString } ${ courseAdminRole } ` , members : [ { displayName : "teacher" , user : { id : 1 } } ] } ) ;
33
45
client . guild . roles . create ( { id : 1 , name : "faculty" , members : [ { displayName : "teacher" , user : { id : 1 } } ] } ) ;
34
46
const response = `No instructors for ${ roleString } ` ;
35
- await execute ( studentInteractionWithoutOptions , client ) ;
47
+ await execute ( studentInteractionWithoutOptions , client , models ) ;
36
48
expect ( sendEphemeral ) . toHaveBeenCalledTimes ( 1 ) ;
37
49
expect ( sendEphemeral ) . toHaveBeenCalledWith ( studentInteractionWithoutOptions , initialResponse ) ;
38
50
expect ( editErrorEphemeral ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -44,7 +56,7 @@ describe("slash instructors command", () => {
44
56
client . guild . roles . create ( { id : 5 , name : `${ roleString } ${ courseAdminRole } ` , members : [ { displayName : "teacher" , user : { id : 1 } } ] } ) ;
45
57
client . guild . roles . create ( { id : 1 , name : "faculty" , members : [ { displayName : "teacher" , user : { id : 1 } } ] } ) ;
46
58
const response = `No instructors for ${ roleString } ` ;
47
- await execute ( defaultStudentInteraction , client ) ;
59
+ await execute ( defaultStudentInteraction , client , models ) ;
48
60
expect ( sendEphemeral ) . toHaveBeenCalledTimes ( 1 ) ;
49
61
expect ( sendEphemeral ) . toHaveBeenCalledWith ( defaultStudentInteraction , initialResponse ) ;
50
62
expect ( editErrorEphemeral ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments