@@ -73,20 +73,20 @@ describe('Test validations from config/validations.js', () => {
7373 expect ( uniqueCodes . size ) . to . equal ( statusCodes . length ) ;
7474 } ) ;
7575
76- it ( 'should validate a manually submitted org code' , ( ) => {
76+ it ( 'should validate a manually submitted status code' , ( ) => {
7777 const orgCode = 'hidden'
7878 expect ( validations . parameters . pathParameters . code ( orgCode ) , `Status code ${ orgCode } should be valid` ) . to . be . true ;
7979 } ) ;
8080
81- it ( 'should reject a manually submitted org code' , ( ) => {
81+ it ( 'should reject a manually submitted status code' , ( ) => {
8282 const orgCode = 'blah_blah_not_valid'
8383 expect ( validations . parameters . pathParameters . code ( orgCode ) , `Status code ${ orgCode } should not be valid` ) . to . be . false ;
8484 } ) ;
8585 } ) ;
8686
8787 describe ( 'validations.parameters.pathParameters.id' , ( ) => {
8888 it ( 'should validate a valid game ID' , ( ) => {
89- const id = 'G-6 ' ;
89+ const id = 'G-92d3ace7 ' ;
9090 expect ( validations . parameters . pathParameters . id ( id ) ) . to . be . true ;
9191 } ) ;
9292
@@ -95,22 +95,39 @@ describe('Test validations from config/validations.js', () => {
9595 expect ( validations . parameters . pathParameters . id ( id ) ) . to . be . false ;
9696 } ) ;
9797
98- it ( 'should reject an invalid game ID based on negative value' , ( ) => {
99- const id = '-1' ;
100- expect ( validations . parameters . pathParameters . id ( id ) ) . to . be . false ;
101- } ) ;
102-
10398 it ( 'should reject an invalid game ID based on length (too long)' , ( ) => {
104- const id = '102 ' ;
99+ const id = 'G-ef89b3c08 ' ;
105100 expect ( validations . parameters . pathParameters . id ( id ) ) . to . be . false ;
106101 } ) ;
107102
108103 it ( 'should reject an invalid game ID based on length (too short)' , ( ) => {
109- const id = 'G-' ;
104+ const id = 'G-c0e6 ' ;
110105 expect ( validations . parameters . pathParameters . id ( id ) ) . to . be . false ;
111106 } ) ;
112107
113108 } )
109+
110+ describe ( 'validations.queryParameters.players' , ( ) => {
111+ it ( 'should validate a valid number of players' , ( ) => {
112+ const players = '5' ;
113+ expect ( validations . parameters . queryParameters . players ( players ) ) . to . be . true ;
114+ } ) ;
115+
116+ it ( 'should reject a number of players that is too low' , ( ) => {
117+ const players = '0' ; // we will not allow the computer to play itself - even if it would learn a valuable lesson
118+ expect ( validations . parameters . queryParameters . players ( players ) ) . to . be . false ;
119+ } ) ;
120+
121+ it ( 'should reject a number of players that is too high' , ( ) => {
122+ const players = '11' ;
123+ expect ( validations . parameters . queryParameters . players ( players ) ) . to . be . false ;
124+ } ) ;
125+
126+ it ( 'should reject a non-numeric value' , ( ) => {
127+ const players = 'invalid' ;
128+ expect ( validations . parameters . queryParameters . players ( players ) ) . to . be . false ;
129+ } ) ;
130+ } ) ;
114131} ) ;
115132
116133/* ****************************************************************************
0 commit comments