server.test.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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, process.env.ORION_QUERY_NODE_URL!)
  13. await server.start()
  14. })
  15. afterEach(async () => {
  16. await server.stop()
  17. await mongoose.disconnect()
  18. })
  19. it('should run without any issues', async () => {
  20. expect(true).toBe(true)
  21. })
  22. it('should start with empty aggregates', async () => {
  23. const videoViewsMap = aggregates.viewsAggregate.getVideoViewsMap()
  24. const channelViewsMap = aggregates.viewsAggregate.getChannelViewsMap()
  25. const channelFollowsMap = aggregates.followsAggregate.getChannelFollowsMap()
  26. expect(videoViewsMap).toEqual({})
  27. expect(channelViewsMap).toEqual({})
  28. expect(channelFollowsMap).toEqual({})
  29. })
  30. })