Test add integration tests for scope
This commit is contained in:
		
							
								
								
									
										40
									
								
								src/crud-scope.integration.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/crud-scope.integration.test.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					import test from 'ava';
 | 
				
			||||||
 | 
					import 'sinon-bluebird';
 | 
				
			||||||
 | 
					import setup from '../test/integration-setup.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const STATUS_OK = 200;
 | 
				
			||||||
 | 
					const STATUS_NOT_FOUND = 404;
 | 
				
			||||||
 | 
					const STATUS_BAD_REQUEST = 400;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					setup(test);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('/players/returnsOne', async (t) => {
 | 
				
			||||||
 | 
					  const { server, instances } = t.context;
 | 
				
			||||||
 | 
					  const { player1 } = instances;
 | 
				
			||||||
 | 
					  const url = '/players/returnsOne';
 | 
				
			||||||
 | 
					  const method = 'GET';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const { result, statusCode } = await server.inject({ url, method });
 | 
				
			||||||
 | 
					  t.is(statusCode, STATUS_OK);
 | 
				
			||||||
 | 
					  t.is(result.length, 1);
 | 
				
			||||||
 | 
					  t.truthy(result[0].id, player1.id);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('/players/returnsNone', async (t) => {
 | 
				
			||||||
 | 
					  const { server } = t.context;
 | 
				
			||||||
 | 
					  const url = '/players/returnsNone';
 | 
				
			||||||
 | 
					  const method = 'GET';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const { statusCode } = await server.inject({ url, method });
 | 
				
			||||||
 | 
					  t.is(statusCode, STATUS_NOT_FOUND);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test('invalid scope /players/invalid', async (t) => {
 | 
				
			||||||
 | 
					  const { server } = t.context;
 | 
				
			||||||
 | 
					  // this doesn't exist in our fixtures
 | 
				
			||||||
 | 
					  const url = '/players/invalid';
 | 
				
			||||||
 | 
					  const method = 'GET';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const { statusCode } = await server.inject({ url, method });
 | 
				
			||||||
 | 
					  t.is(statusCode, STATUS_BAD_REQUEST);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
		Reference in New Issue
	
	Block a user