-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_DATA.test.jsx
47 lines (39 loc) · 1.26 KB
/
_DATA.test.jsx
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
const { _saveQuestionAnswer, _saveQuestion } = require("./_DATA");
describe("_saveQuestion", () => {
it("should return true for correct parameters", async () => {
const response = await _saveQuestion({
optionOneText: "learn English",
optionTwoText: "learn Arabic",
author: "br19",
});
expect(response).toBeTruthy();
});
it("should return error for false parameters", async () => {
const response = await _saveQuestion({
optionOneText: "learn English",
optionTwoText: "learn Arabic",
author: undefined,
}).catch((e) => e);
expect(response).toBe(
"Please provide optionOneText, optionTwoText, and author"
);
});
});
describe("_saveQuestionAnswer", () => {
it("should return true for correct parameters", async () => {
const response = await _saveQuestionAnswer({
authedUser: "tylermcginnis",
qid: "8xf0y6ziyjabvozdd253nd",
answer: "optionOne",
});
expect(response).toBeTruthy();
});
it("should return error for false parameters", async () => {
const response = await _saveQuestionAnswer({
authedUser: "br19",
qid: undefined,
answer: "optionOne",
}).catch((e) => e);
expect(response).toBe("Please provide authedUser, qid, and answer");
});
});