schild.test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // import { Schild } from '../dist/schild.esm'
  2. const Schild = require("../dist/schild.cjs")
  3. const connectionString = {
  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. const schild = new Schild()
  15. schild.connect(connectionString)
  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. test('getNutzer', async () => {
  48. expect.assertions(1)
  49. expect(await schild.getNutzer('hmt')).toHaveProperty('US_Privileges', '$')
  50. })
  51. })