traceView.spec.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {TraceView} from './traceView';
  2. describe('TraceView', () => {
  3. it('does not allow setting trace view width to 0', () => {
  4. const view = new TraceView();
  5. view.setTraceView({width: 0});
  6. expect(view.trace_view.width).toBeGreaterThan(0);
  7. });
  8. describe('getConfigSpaceCursor', () => {
  9. it('returns the correct x position', () => {
  10. const view = new TraceView();
  11. view.setTraceSpace([0, 0, 100, 1]);
  12. view.setTracePhysicalSpace([0, 0, 1000, 1], [0, 0, 1000, 1]);
  13. expect(view.getConfigSpaceCursor({x: 500, y: 0})).toEqual([50, 0]);
  14. });
  15. it('returns the correct x position when view scaled', () => {
  16. const view = new TraceView();
  17. view.setTraceSpace([0, 0, 100, 1]);
  18. view.setTracePhysicalSpace([0, 0, 1000, 1], [0, 0, 1000, 1]);
  19. view.setTraceView({x: 50, width: 50});
  20. expect(view.getConfigSpaceCursor({x: 500, y: 0})).toEqual([75, 0]);
  21. });
  22. it('returns the correct x position when view is offset', () => {
  23. const view = new TraceView();
  24. view.setTraceSpace([0, 0, 100, 1]);
  25. view.setTracePhysicalSpace([0, 0, 1000, 1], [0, 0, 1000, 1]);
  26. view.setTraceView({x: 50, width: 50});
  27. // Half of the right quadrant
  28. expect(view.getConfigSpaceCursor({x: 500, y: 0})).toEqual([75, 0]);
  29. });
  30. });
  31. });