Framework for building UIs for OpenStack projects dealing with complex input data
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

workbook.controller.spec.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* Copyright (c) 2015 Mirantis, Inc.
  2. Licensed under the Apache License, Version 2.0 (the "License"); you may
  3. not use this file except in compliance with the License. You may obtain
  4. a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  8. WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  9. License for the specific language governing permissions and limitations
  10. under the License.
  11. */
  12. describe('together workbook model and controller', function() {
  13. var models, utils, workbook;
  14. beforeEach(function () {
  15. module('mistral');
  16. inject(function ($injector) {
  17. models = $injector.get('mistral.workbook.models');
  18. utils = $injector.get('merlin.utils');
  19. });
  20. workbook = models.Workbook.create();
  21. });
  22. describe('define top-level actions available to user:', function () {
  23. var wbCtrl;
  24. beforeEach(inject(function (_$controller_) {
  25. wbCtrl = _$controller_('WorkbookController', {});
  26. wbCtrl.workbook = workbook;
  27. }));
  28. describe("'Add Action' action", function () {
  29. it('adds a new Action', function () {
  30. wbCtrl.addAction();
  31. expect(workbook.get('actions').get(0)).toBeDefined();
  32. });
  33. it('creates action with predefined name', function () {
  34. wbCtrl.addAction();
  35. expect(workbook.get('actions').get(0).getID()).toBeGreaterThan('');
  36. });
  37. describe('', function () {
  38. var actionID;
  39. beforeEach(inject(function (baseActionID) {
  40. actionID = baseActionID + '1';
  41. }));
  42. it("corresponding JSON has the right key for the Action", function () {
  43. wbCtrl.addAction();
  44. expect(workbook.toJSON({pretty: true}).actions[actionID]).toBeDefined();
  45. });
  46. it("once the Action ID is changed, it's reflected in JSON", function () {
  47. var newID = 'action10';
  48. wbCtrl.addAction();
  49. workbook.get('actions').getByID(actionID).setID(newID);
  50. expect(workbook.toJSON({pretty: true}).actions[actionID]).toBeUndefined();
  51. expect(workbook.toJSON({pretty: true}).actions[newID]).toBeDefined();
  52. });
  53. });
  54. it('creates actions with different names on 2 successive calls', function () {
  55. wbCtrl.addAction();
  56. wbCtrl.addAction();
  57. expect(workbook.get('actions').get(0).getID()).not.toEqual(
  58. workbook.get('actions').get(1).getID())
  59. });
  60. });
  61. describe("'Add Workflow' action", function () {
  62. it('adds a new Workflow', function () {
  63. wbCtrl.addWorkflow();
  64. expect(workbook.get('workflows').get(0)).toBeDefined();
  65. });
  66. describe('', function () {
  67. var workflowID;
  68. beforeEach(inject(function (baseWorkflowID) {
  69. workflowID = baseWorkflowID + '1';
  70. }));
  71. it("corresponding JSON has the right key for the Workflow", function () {
  72. wbCtrl.addWorkflow();
  73. expect(workbook.toJSON({pretty: true}).workflows[workflowID]).toBeDefined();
  74. });
  75. it("once the workflow ID is changed, it's reflected in JSON", function () {
  76. var newID = 'workflow10';
  77. wbCtrl.addWorkflow();
  78. workbook.get('workflows').getByID(workflowID).setID(newID);
  79. expect(workbook.toJSON({pretty: true}).workflows[workflowID]).toBeUndefined();
  80. expect(workbook.toJSON({pretty: true}).workflows[newID]).toBeDefined();
  81. });
  82. });
  83. it('creates workflow with predefined name', function () {
  84. wbCtrl.addWorkflow();
  85. expect(workbook.get('workflows').get(0).getID()).toBeGreaterThan('');
  86. });
  87. it('creates workflows with different names on 2 successive calls', function () {
  88. wbCtrl.addWorkflow();
  89. wbCtrl.addWorkflow();
  90. expect(workbook.get('workflows').get(0).getID()).not.toEqual(
  91. workbook.get('workflows').get(1).getID())
  92. });
  93. });
  94. describe("'Create'/'Modify'/'Cancel' actions", function () {
  95. it('edit causes a request to an api and a return to main page', function () {
  96. });
  97. it('cancel causes just a return to main page', function () {
  98. });
  99. });
  100. })
  101. });