@@ -6,7 +6,6 @@ import Player from '../../../../src/entities/player'
66import Game from '../../../../src/entities/game'
77import APIKey , { APIKeyScope } from '../../../../src/entities/api-key'
88import { createToken } from '../../../../src/services/api-keys.service'
9- import Event from '../../../../src/entities/event'
109import UserFactory from '../../../fixtures/UserFactory'
1110import PlayerFactory from '../../../fixtures/PlayerFactory'
1211import GameFactory from '../../../fixtures/GameFactory'
@@ -31,12 +30,6 @@ describe('Events API service - post', () => {
3130 await ( < EntityManager > app . context . em ) . persistAndFlush ( [ apiKey , validPlayer ] )
3231 } )
3332
34- beforeEach ( async ( ) => {
35- const repo = ( < EntityManager > app . context . em ) . getRepository ( Event )
36- const events = await repo . findAll ( )
37- await repo . removeAndFlush ( events )
38- } )
39-
4033 afterAll ( async ( ) => {
4134 await ( < EntityManager > app . context . em ) . getConnection ( ) . close ( )
4235 } )
@@ -46,14 +39,15 @@ describe('Events API service - post', () => {
4639 await ( < EntityManager > app . context . em ) . flush ( )
4740 token = await createToken ( apiKey )
4841
49- await request ( app . callback ( ) )
42+ const res = await request ( app . callback ( ) )
5043 . post ( `${ baseUrl } ` )
5144 . send ( { events : [ { name : 'Craft bow' , aliasId : validPlayer . aliases [ 0 ] . id , timestamp : Date . now ( ) } ] } )
5245 . auth ( token , { type : 'bearer' } )
5346 . expect ( 200 )
5447
55- const event = await ( < EntityManager > app . context . em ) . getRepository ( Event ) . findOne ( { name : 'Craft bow' } )
56- expect ( event ) . toBeTruthy ( )
48+ expect ( res . body . events ) . toHaveLength ( 1 )
49+ expect ( res . body . events [ 0 ] . name ) . toBe ( 'Craft bow' )
50+ expect ( res . body . events [ 0 ] . playerAlias . id ) . toBe ( validPlayer . aliases [ 0 ] . id )
5751 } )
5852
5953 it ( 'should create multiple events if the scope is valid' , async ( ) => {
0 commit comments