-
Notifications
You must be signed in to change notification settings - Fork 16
/
crud_test.js
70 lines (68 loc) · 2.16 KB
/
crud_test.js
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
"use strict";
var assert = require('assert');
module.exports = {
suite: {
name: "Parse CRUD",
tests: [
{
name: "create_get_list_update_delete",
description: "You can create a Parse object, get and list it, update its name, and then delete it",
api_calls: [
{
it: "can create a GameScore object",
request: "POST /classes/GameScore",
params: "{{users.joe}}",
status: 201,
assert: function(body) {
assert(body.createdAt);
assert(new Date(body.createdAt) > new Date());
this.users.joe.objectId = body.objectId; // save the ID
}
},
{
it: "can get the created GameScore object",
request: "GET /classes/GameScore/{{users.joe.objectId}}",
assert: function(body) {
assert.equal(body.playerName, this.users.joe.playerName);
}
},
{
it: "can list GameScore objects",
request: "GET /classes/GameScore",
params: {
order: "-created_at",
limit: 3
},
assert: function(body) {
assert.equal(body.results.length, 3);
assert.equal(body.results[0].objectId, this.users.joe.objectId);
}
},
{
it: "can update name of GameScore object",
request: "PUT /classes/GameScore/{{users.joe.objectId}}",
params: {
playerName: "New name"
}
},
{
it: "can get new name of GameScore object",
request: "GET /classes/GameScore/{{users.joe.objectId}}",
assert: function(body) {
assert.equal(body.playerName, "New name");
}
},
{
it: "can delete GameScore object",
request: "DELETE /classes/GameScore/{{users.joe.objectId}}"
},
{
it: "can verify that GameScore object was deleted",
request: "GET /classes/GameScore/{{users.joe.objectId}}",
status: 404
}
]
}
]
}
};