schild.test.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const schild = require('../schild')
  2. const connectionString = {
  3. testing: {
  4. client: 'mysql',
  5. useNullAsDefault: true,
  6. connection: {
  7. host: 'localhost',
  8. database: 'schild_berufskolleg',
  9. user: 'schild',
  10. password: 'schild',
  11. charset: 'utf8'
  12. }
  13. }
  14. }
  15. schild.connect(connectionString, 'testing')
  16. afterAll(() => {
  17. schild.disconnect()
  18. })
  19. describe('schild Methoden', () => {
  20. test('connection test', async () => {
  21. expect.assertions(1)
  22. expect(await schild.testConnection).toBeTruthy()
  23. })
  24. test('suche', async () => {
  25. expect.assertions(2)
  26. expect((await schild.suche('C1'))[0]).toHaveProperty('id')
  27. expect((await schild.suche('Denise'))[0]).toHaveProperty('id')
  28. })
  29. test('getSchueler', async () => {
  30. expect.assertions(2)
  31. expect(await schild.getSchueler(1942)).toHaveProperty('ID', 1942)
  32. expect((await schild.getSchueler(1623)).abschnitte).toHaveLength(4)
  33. })
  34. test('getKlasse', async () => {
  35. expect.assertions(2)
  36. expect((await schild.getKlasse('C16A2')).schueler).toHaveLength(27)
  37. expect((await schild.getKlasse('C16A2')).schueler[0]).toHaveProperty('ID', 1942)
  38. })
  39. test('getSchule', async () => {
  40. expect.assertions(1)
  41. expect(await schild.getSchule()).toHaveProperty('Ort', 'Bielefeld')
  42. })
  43. test('getSchuelerfoto', async () => {
  44. expect.assertions(1)
  45. expect(await schild.getSchuelerfoto(1234)).toContain('/9j/4')
  46. })
  47. })