@@ -48,61 +48,95 @@ vows.describe("People API").addBatch({
4848 } ,
4949 } ,
5050 'create question set' : {
51- topic : function ( create_err , person ) {
52- blockscore . question_sets . create ( person . id , this . callback ) ;
53- } ,
54- 'got newly created question set' : function ( err , response ) {
55- assert . ifError ( err ) ;
56- assert . ok ( response . person_id ) ;
57- assert . ok ( response . id ) ;
58- assert . ok ( Array . isArray ( response . questions ) ) ;
59- assert . ok ( Array . isArray ( response . questions [ 0 ] . answers ) ) ;
51+ topic : function ( create_err , person ) {
52+ // pass our person on to our different question set topics
53+ this . callback ( create_err , person ) ;
6054 } ,
61- 'retrieve question set' : {
62- topic : function ( err , create_response ) {
63- var self = this ;
64- blockscore . question_sets . retrieve ( create_response . id , function ( err , response ) {
65- self . callback ( err , response , create_response ) ;
66- } ) ;
55+ 'without a time limit' : {
56+ topic : function ( create_err , person ) {
57+ blockscore . question_sets . create ( person . id , this . callback ) ;
6758 } ,
68- 'check question set is same as when created ' : function ( err , retrieve_response , create_response ) {
59+ 'got newly created question set ' : function ( err , response ) {
6960 assert . ifError ( err ) ;
70- assert . deepEqual ( retrieve_response , create_response ) ;
61+ assert . ok ( response . person_id ) ;
62+ assert . ok ( response . id ) ;
63+ assert . ok ( Array . isArray ( response . questions ) ) ;
64+ assert . ok ( Array . isArray ( response . questions [ 0 ] . answers ) ) ;
65+ } ,
66+ 'retrieve question set' : {
67+ topic : function ( err , create_response ) {
68+ var self = this ;
69+ blockscore . question_sets . retrieve ( create_response . id , function ( err , response ) {
70+ self . callback ( err , response , create_response ) ;
71+ } ) ;
72+ } ,
73+ 'check question set is same as when created' : function ( err , retrieve_response , create_response ) {
74+ assert . ifError ( err ) ;
75+ assert . deepEqual ( retrieve_response , create_response ) ;
76+ }
77+ } ,
78+ 'score question set' : {
79+ topic : function ( err , response ) {
80+ var data = {
81+ id : response . id ,
82+ answers : [
83+ {
84+ question_id : 1 ,
85+ answer_id : 1
86+ } ,
87+ {
88+ question_id : 2 ,
89+ answer_id : 1
90+ } ,
91+ {
92+ question_id : 3 ,
93+ answer_id : 1
94+ } ,
95+ {
96+ question_id : 4 ,
97+ answer_id : 1
98+ } ,
99+ {
100+ question_id : 5 ,
101+ answer_id : 1
102+ }
103+ ]
104+ } ;
105+ blockscore . question_sets . score ( data , this . callback ) ;
106+ } ,
107+ 'Got score' : function ( err , response ) {
108+ assert . ifError ( err ) ;
109+ assert . ok ( response . id ) ;
110+ assert . ok ( typeof response . score == 'number' ) ;
111+ }
71112 }
72113 } ,
73- 'score question set' : {
74- topic : function ( err , response ) {
75- var data = {
76- id : response . id ,
77- answers : [
78- {
79- question_id : 1 ,
80- answer_id : 1
81- } ,
82- {
83- question_id : 2 ,
84- answer_id : 1
85- } ,
86- {
87- question_id : 3 ,
88- answer_id : 1
89- } ,
90- {
91- question_id : 4 ,
92- answer_id : 1
93- } ,
94- {
95- question_id : 5 ,
96- answer_id : 1
97- }
98- ]
99- } ;
100- blockscore . question_sets . score ( data , this . callback ) ;
114+ 'with a time limit' : {
115+ topic : function ( create_err , person ) {
116+ blockscore . question_sets . create ( {
117+ person_id : person . id ,
118+ time_limit : 42
119+ } , this . callback ) ;
101120 } ,
102- 'Got score ' : function ( err , response ) {
121+ 'got newly created question set ' : function ( err , response ) {
103122 assert . ifError ( err ) ;
123+ assert . ok ( response . person_id ) ;
104124 assert . ok ( response . id ) ;
105- assert . ok ( typeof response . score == 'number' ) ;
125+ assert . ok ( Array . isArray ( response . questions ) ) ;
126+ assert . ok ( Array . isArray ( response . questions [ 0 ] . answers ) ) ;
127+ assert . equal ( response . time_limit , 42 ) ;
128+ } ,
129+ 'retrieve question set' : {
130+ topic : function ( err , create_response ) {
131+ var self = this ;
132+ blockscore . question_sets . retrieve ( create_response . id , function ( err , response ) {
133+ self . callback ( err , response , create_response ) ;
134+ } ) ;
135+ } ,
136+ 'check question set is same as when created' : function ( err , retrieve_response , create_response ) {
137+ assert . ifError ( err ) ;
138+ assert . deepEqual ( retrieve_response , create_response ) ;
139+ }
106140 }
107141 }
108142 }
0 commit comments