-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest.js
More file actions
110 lines (85 loc) · 4.01 KB
/
Test.js
File metadata and controls
110 lines (85 loc) · 4.01 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
// jshint esversion: 8
// NOTE: Everytime db is required, it opens a new connection.
// Once max connections reached must restart computer.
require('./models/db');
const mongoose = require('mongoose');
const ctrlCourse = require('./controllers/course');
const ctrlStudent = require('./controllers/student');
const Course = require('./models/Course');
const Student = require('./models/Student');
const coursesCreate = ctrlCourse.coursesCreate;
const coursesReadAll = ctrlCourse.coursesReadAll;
const coursesDeleteAll = ctrlCourse.coursesDeleteAll;
const coursesReadOne = ctrlCourse.coursesReadOne;
const coursesUpdateOne = ctrlCourse.coursesUpdateOne;
const coursesDeleteOne = ctrlCourse.coursesDeleteOne;
const studentsCreate = ctrlStudent.studentsCreate;
const studentsReadAll = ctrlStudent.studentsReadAll;
const studentsDeleteAll = ctrlStudent.studentsDeleteAll;
const studentsReadOne = ctrlStudent.studentsReadOne;
const studentsUpdateOne = ctrlStudent.studentsUpdateOne;
const studentsDeleteOne = ctrlStudent.studentsDeleteOne;
const studentsUpdateAnswers = ctrlStudent.studentsUpdateAnswers;
// COURSES TESTING
const create_courses = function() {
// CREATE COURSES
// Create Course without anything (should return error)
coursesCreate().then(response => console.log("1: " + response));
// Create Course with just name
coursesCreate({ course: "CS 1500", courseName: "Databases for Idiots"}).then(response => console.log("2: " + response));
// Test Duplicate
coursesCreate({ course: "CS 1400"}).then(response => console.log("3: " + response));
coursesCreate({ course: "CS 1400"}).then(response => console.log("4: " + response));
// Should have CS 1400 and CS 1500
// coursesReadAll().then(response => (console.log("All courses: \n" + response)));
};
const create_students = function() {
// CREATE STUDENTS
studentsCreate({ studentTag: "DISCORDID1" })
.then(createdStudent => console.log(createdStudent));
// Duplicate Test
studentsCreate({ studentTag: "DISCORDID2", name: "Big Mac", classification: "Sophomore", major: "Business", adminStatus: true })
.then(createdStudent => console.log(createdStudent));
// Should have two students
// studentsReadAll().then(response => (console.log("All Students: \n" + response)));
};
const reading = function() {
studentsReadOne("DISCORDID2").then(res => console.log(res));
coursesReadOne("CS 1400").then(res => (console.log(res)));
};
const updateTests = function() {
// COURSES UPDATE
// check adding and deleting students to and from courses SUCCESS
// coursesUpdateOne({ course: "CS 1400", newCourseName: "poop class", studentToAddTag: "DISCORDID2" });
// coursesUpdateOne({ course: "CS 1400", studentToRemoveTag: "DISCORDID1" });
//
// coursesUpdateOne({ course: "CS 1500", newCourseName: "poop class 2", studentToAddTag: "DISCORDID2" });
// coursesUpdateOne({ course: "CS 1500", studentToAddTag: "DISCORDID1" });
// check deleteStudents functionality
// coursesUpdateOne( { course: "CS 1500", deleteStudents: true} );
// STUDENTS UPDATE
// check adding and deleting courses to and from students
// studentsUpdateOne({ courseToAdd: "CS 1400", studentTag: "DISCORDID2", newStudentName: "John", newStudentClassification: "Freshman",
// newStudentMajor: "Dog", toggleAdminStatus: true });
// studentsUpdateOne({ studentTag: "DISCORDID2", deleteCourses: true });
// check all students update functionality
};
// Read All SUCCESS
studentsReadAll().then(response => (console.log("All Students: \n" + response)));
// coursesReadAll().then(response => (console.log("All courses: \n" + response)));
// All FAILURE
// updateTests();
// DeleteOne Functionality here FAILURE
// studentsDeleteOne("DISCORDID2");
// coursesDeleteOne("CS 1400");
// Test with arrays filled SUCCESS
// reading();
// Creating courses SUCCESS
// create_courses();
// Creating students SUCCESS
// create_students();
// Delete all students and courses SUCCESS
// studentsDeleteAll();
// coursesDeleteAll();
// Test updated answers
// studentsUpdateAnswers('DISCORDID1', ["Answer 1", "Answer 2"]);