server.test.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { buildAggregates, connectMongoose, createServer } from '../src/server'
  2. import { Mongoose } from 'mongoose'
  3. import { ApolloServer } from 'apollo-server-express'
  4. import { Aggregates } from '../src/types'
  5. describe('The server', () => {
  6. let server: ApolloServer
  7. let mongoose: Mongoose
  8. let aggregates: Aggregates
  9. beforeEach(async () => {
  10. mongoose = await connectMongoose(process.env.MONGO_URL!)
  11. aggregates = await buildAggregates()
  12. server = await createServer(mongoose, aggregates)
  13. })
  14. afterEach(async () => {
  15. await server.stop()
  16. await mongoose.disconnect()
  17. })
  18. it('should run without any issues', async () => {
  19. expect(true).toBe(true)
  20. })
  21. it('should start with empty aggregates', async () => {
  22. const videoViewsMap = aggregates.viewsAggregate.getVideoViewsMap()
  23. const channelViewsMap = aggregates.viewsAggregate.getChannelViewsMap()
  24. const allViewsEvents = aggregates.viewsAggregate.getAllViewsEvents()
  25. const channelFollowsMap = aggregates.followsAggregate.getChannelFollowsMap()
  26. expect(videoViewsMap).toEqual({})
  27. expect(channelViewsMap).toEqual({})
  28. expect(channelFollowsMap).toEqual({})
  29. expect(allViewsEvents).toHaveLength(0)
  30. })
  31. })