Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

notification.spec.js 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict'
  2. const test = require('ava')
  3. const Hapi = require('@hapi/hapi')
  4. const plugin = require('../lib/plugins/notification')
  5. /**
  6. * Route parameters
  7. */
  8. const params = {
  9. profile_id: 37,
  10. }
  11. const mockReturn = {
  12. queue: [
  13. { mocked_profile_id: 1, target_id: 2, is_deleted: false },
  14. { mocked_profile_id: 2, target_id: 3, is_deleted: false },
  15. { mocked_profile_id: 3, target_id: 1, is_deleted: false },
  16. ],
  17. }
  18. const pathToTest = {
  19. method: 'GET',
  20. url: `/${params.profile_id}/subscribe`,
  21. }
  22. test('path /subscribe should return ok on GET', async t => {
  23. /**
  24. * Create a new server and register services,
  25. * models and routes for testing
  26. * -
  27. * NOTE: We use a mocked registerModel() and register
  28. * models manually. Normally this is handled by
  29. * Schwifty at runtime.
  30. */
  31. const server = Hapi.server()
  32. /**
  33. * Register Routes and Services as usual
  34. */
  35. await plugin.register(server)
  36. /**
  37. * Test the server with registered models and services
  38. */
  39. // const { payload } = await server.inject(pathToTest)
  40. // const res = JSON.parse(payload)
  41. // t.deepEqual(res.ok, true)
  42. // t.deepEqual(
  43. // res.data,
  44. // mockReturn.queue.map(entry => entry.target_id),
  45. // )
  46. server.stop()
  47. t.is(true, true)
  48. })