2
0

voting-cards.spec.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2018 Scytl Secure Electronic Voting SA
  3. *
  4. * All rights reserved
  5. *
  6. * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
  7. */
  8. describe('voting-cards.js', function() {
  9. 'use strict';
  10. beforeEach(module('endpoints'));
  11. beforeEach(module('gettext'));
  12. beforeEach(module('voting-cards'));
  13. describe('filters', function() {
  14. function seconds(time) {
  15. return time * 1000;
  16. }
  17. function minutes(time) {
  18. return seconds(time) * 60;
  19. }
  20. function hours(time) {
  21. return minutes(time) * 60;
  22. }
  23. it('Should show elapsed time formatted', inject(function($filter) {
  24. var elapsed = $filter('elapsed');
  25. var time = seconds(0);
  26. expect(elapsed(time)).toBe('0 seconds');
  27. time = seconds(1);
  28. expect(elapsed(time)).toBe('1 seconds');
  29. time = seconds(59);
  30. expect(elapsed(time)).toBe('59 seconds');
  31. time = seconds(60);
  32. expect(elapsed(time)).toBe('1 minute');
  33. time = seconds(61);
  34. expect(elapsed(time)).toBe('1 minute 1 seconds');
  35. time = minutes(59);
  36. expect(elapsed(time)).toBe('59 minutes 0 seconds');
  37. time = minutes(60);
  38. expect(elapsed(time)).toBe('1 hour 0 minutes');
  39. time = minutes(61);
  40. expect(elapsed(time)).toBe('1 hour 1 minutes');
  41. time = hours(2);
  42. expect(elapsed(time)).toBe('2 hours 0 minutes');
  43. }));
  44. });
  45. });