2
0

ballot-printer.spec.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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('Ballot printer ...', function() {
  9. 'use strict';
  10. beforeEach(module('lodash'));
  11. beforeEach(module('ballotprinter'));
  12. var response = [{
  13. // "ballot": {
  14. "id": "3c37a341fd724e36b117004619142782",
  15. "electionEvent": {
  16. "id": "90053f72699049298cf39f1b13daf9c8"
  17. },
  18. "defaultTitle": "LEGISLATIVE 2017 - T1 CC 09",
  19. "defaultDescription": "09",
  20. "alias": "09",
  21. "contests": [{
  22. "id": "0a220b1a566a4ac28f6e6faaad5c267d",
  23. "defaultTitle": "LEGISLATIVE 2017 - T1 CC 09",
  24. "defaultDescription": "09",
  25. "alias": "09",
  26. "electionEvent": {
  27. "id": "90053f72699049298cf39f1b13daf9c8"
  28. },
  29. "type": "votation",
  30. "options": [{
  31. "id": "7a3ab02e7dea414aac881e9dcd5007f7",
  32. "defaultText": "eyJvcmRlciI6MSwiY2FuZGlkYXRlIjp7Im5hbWUiOiJQcsOpbm9tIDA5MDEiLCJzdXJuYW1lIjoiTEVHSVNMQVRJVkUgMDkwMSIsInRpdGxlIjoiTS4ifSwiYnVsbGV0aW4iOiIwOTEwOV9CdWxsZXRpbi5wbmciLCJjaXJjdWxhciI6IjA5MTA5X0NpcmN1bGFyLnBkZiIsImFsdGVybmF0ZSI6eyJuYW1lIjoiUHLDqW5vbSBTIDA5MDEiLCJzdXJuYW1lIjoiTEVHSVNMQVRJVkUgUyAwOTAxIiwidGl0bGUiOiJNLiJ9fQ==",
  33. "alias": "091",
  34. "representation": "2",
  35. "attributes": [
  36. "bf75541c34874d24b3f2f72ebc815b6f",
  37. "3b2a6f9132114619a664f5b742b9aabf"
  38. ]
  39. }, {
  40. "id": "70bf9d742a0c424695c6392f1c90bf66",
  41. "defaultText": "tralala",
  42. "alias": "092",
  43. "representation": "3",
  44. "attributes": [
  45. "bf75541c34874d24b3f2f72ebc815b6f",
  46. "3b2a6f9132114619a664f5b742b9aabf"
  47. ]
  48. }],
  49. "optionsAttributes": [{
  50. "id": "3b2a6f9132114619a664f5b742b9aabf",
  51. "type": "contestgroup",
  52. "correctness": true
  53. }, {
  54. "id": "bf75541c34874d24b3f2f72ebc815b6f",
  55. "defaultText": "LEGISLATIVE 2017 - T1 - Question",
  56. "type": "group",
  57. "alias": "Maedi_Question_1",
  58. "correctness": true
  59. }],
  60. "clauses": [{
  61. "id": "fdc166491b4243f3966c3821abbc5cc1",
  62. "refersTo": "3b2a6f9132114619a664f5b742b9aabf",
  63. "type": "MIN",
  64. "value": 1
  65. }, {
  66. "id": "cbeb2d64956647a0b9a09d7905b5b6cf",
  67. "refersTo": "3b2a6f9132114619a664f5b742b9aabf",
  68. "type": "MAX",
  69. "value": 1
  70. }, {
  71. "id": "7e8e90c9f1bd46f79fc2c7cc9e16764c",
  72. "refersTo": "bf75541c34874d24b3f2f72ebc815b6f",
  73. "type": "MIN",
  74. "value": 1
  75. }, {
  76. "id": "4f180a291c5941e7b0f458a8cf4b7470",
  77. "refersTo": "bf75541c34874d24b3f2f72ebc815b6f",
  78. "type": "MAX",
  79. "value": 1
  80. }]
  81. }]
  82. // }
  83. }];
  84. describe('should expand option.defaultText to ...', function() {
  85. beforeEach(inject(function(ballotprinter) {
  86. ballotprinter.print(response);
  87. }));
  88. it('candidate data if it is valid b64 encoded JSON', function() {
  89. expect(response[0].contests[0].options[0].defaultText).toEqual({
  90. order: 1,
  91. candidate: Object({
  92. name: 'Prénom 0901',
  93. surname: 'LEGISLATIVE 0901',
  94. title: 'M.'
  95. }),
  96. bulletin: '09109_Bulletin.png',
  97. circular: '09109_Circular.pdf',
  98. alternate: Object({
  99. name: 'Prénom S 0901',
  100. surname: 'LEGISLATIVE S 0901',
  101. title: 'M.'
  102. })
  103. });
  104. });
  105. it('nothing if not valid b64 or JSON', function() {
  106. expect(response[0].contests[0].options[1].defaultText).toBe('tralala');
  107. });
  108. });
  109. });