File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 "db" : {
33 "name" : " db" ,
44 "connector" : " memory"
5+ },
6+ "fullstack" : {
7+ "name" : " fullstack" ,
8+ "connector" : " memory"
59 }
610}
Original file line number Diff line number Diff line change 1+ {
2+ "db" : {
3+ "name" : " db" ,
4+ "connector" : " memory"
5+ }
6+ }
Original file line number Diff line number Diff line change 1+ /**
2+ * Created by rauldablaing on 1/19/15.
3+ */
4+
5+ /* jshint quotmark:false */
6+
7+ // Add dependencies
8+ var frisby = require ( 'frisby' ) ;
9+ var url = 'http://localhost:3000/api/students/' ;
10+ var initialStudent = {
11+ "firstName" : "Jojo" ,
12+ "lastName" : "Jones"
13+ } ;
14+ var newCourse = {
15+ "title" : "Java" ,
16+ "courseType" : "Programming" ,
17+ "description" : "Basics"
18+ } ;
19+ // Set up variables for info you will use often
20+ frisby . create ( 'Create contact with post' )
21+ . post ( 'http://localhost:3000/api/students' ,
22+ initialStudent ,
23+ { json : true } )
24+ . expectStatus ( 200 )
25+ . afterJSON ( function ( json ) {
26+ getRecord ( json . id ) ;
27+ }
28+ )
29+ . toss ( ) ;
30+
31+
32+ // Read a record
33+ function getRecord ( id ) {
34+ frisby . create ( 'Get student using id' )
35+ . get ( url + id )
36+ . expectStatus ( 200 )
37+ . expectJSON ( initialStudent )
38+ . afterJSON ( function ( json ) {
39+ putRecord ( json . id ) ;
40+ } )
41+ . toss ( ) ;
42+ }
43+
44+ function putRecord ( id ) {
45+ frisby . create ( 'Put student using id' )
46+ . put ( url + id , {
47+ "firstName" : "Chuck" ,
48+ "lastName" : "Luck"
49+ } , { json :true } )
50+ . expectStatus ( 200 )
51+ . expectJSON ( {
52+ "firstName" : "Chuck" ,
53+ "lastName" : "Luck"
54+ } )
55+ . afterJSON ( function ( json ) {
56+ testCourse ( id ) ;
57+ } )
58+ . toss ( ) ;
59+ }
60+
61+ function testCourse ( id ) {
62+ frisby . create ( 'Create course to student' )
63+ . post ( url + id + '/courses' , newCourse )
64+ . expectStatus ( 200 )
65+ . expectJSON ( newCourse )
66+ . afterJSON ( function ( json ) {
67+ deleteRecord ( json . id ) ;
68+ } )
69+ . toss ( ) ;
70+ }
71+
72+ function deleteRecord ( id ) {
73+ frisby . create ( 'Delete student using id' )
74+ . delete ( url + id )
75+ . expectStatus ( 204 )
76+ . toss ( ) ;
77+ }
78+
79+
80+
You can’t perform that action at this time.
0 commit comments