server.test.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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 channelFollowsMap = aggregates.followsAggregate.getChannelFollowsMap()
  25. expect(videoViewsMap).toEqual({})
  26. expect(channelViewsMap).toEqual({})
  27. expect(channelFollowsMap).toEqual({})
  28. })
  29. })