Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { expect, test } from 'vitest'
  2. import { Channel, Reading } from '../src/core/channel'
  3. import { Controller } from '../src/controller'
  4. test('controller - updates correctly', () => {
  5. let mockTemp = 70
  6. let testReader = new Reading({
  7. onRead: () => mockTemp,
  8. unit: 'F',
  9. max: 100,
  10. min: 50,
  11. })
  12. let testChan = new Channel({ interval: 1, reader: testReader })
  13. const testController = new Controller({
  14. type: 'blah',
  15. channel: testChan,
  16. })
  17. expect(testController.inRange).toBe(true)
  18. mockTemp = 101
  19. testController.update()
  20. expect(testController.inRange).toBe(false)
  21. testController.onUpdate = foo => 'foo'
  22. expect(testController.onUpdate('bar')).toBe('foo')
  23. })
  24. test('controller - onUpdate overloading works', () => {
  25. let mockTemp = 70
  26. let testReader = new Reading({
  27. onRead: () => mockTemp,
  28. unit: 'F',
  29. max: 100,
  30. min: 50,
  31. })
  32. let testChan = new Channel({ interval: 1, reader: testReader })
  33. const testController = new Controller({
  34. type: 'blah',
  35. channel: testChan,
  36. })
  37. testController.onUpdate = foo => 'foo'
  38. expect(testController.onUpdate('bar')).toBe('foo')
  39. })