voting-card-set-service.spec.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 card set service", function () {
  9. var votingCardSetService, httpBackend;
  10. beforeEach(module("votingCardSet"));
  11. beforeEach(inject(function (_votingCardSetService_, $httpBackend) {
  12. votingCardSetService = _votingCardSetService_;
  13. httpBackend = $httpBackend;
  14. }));
  15. it("should change status", function () {
  16. // Define a minimal voting card set.
  17. var votingCardSet = {
  18. id: "votingCard",
  19. electionEvent: {
  20. id: "electionEvent"
  21. },
  22. status: 'LOCKED'
  23. };
  24. // Attempt to chage status.
  25. httpBackend.whenPUT("/votingcardset/electionevent/electionEvent/votingcardset/votingCardSet").respond({
  26. data: {
  27. status: 'PRECOMPUTED'
  28. }
  29. });
  30. votingCardSetService.changeStatus(votingCardSet, "PRECOMPUTED").then(function(data) {
  31. expect(data.status).toEqual('PRECOMPUTED');
  32. });
  33. httpBackend.flush();
  34. });
  35. });