~ubuntu-branches/ubuntu/wily/horizon/wily-proposed

« back to all changes in this revision

Viewing changes to openstack_dashboard/static/app/core/openstack-service-api/policy.service.spec.js

  • Committer: Package Import Robot
  • Author(s): Corey Bryant
  • Date: 2015-09-08 15:52:37 UTC
  • mfrom: (0.20.1) (0.19.3)
  • Revision ID: package-import@ubuntu.com-20150908155237-7muid4idbm4qdelw
Tags: 2:8.0.0~b3-0ubuntu1
* New upstream milestone for OpenStack Liberty.
* d/control: Align (build-)depends with upstream.
* d/p/ubuntu_settings.patch: Rebased.
* d/p/embedded-xstatic.patch: Rebased.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *    (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *    http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
(function() {
 
18
  'use strict';
 
19
 
 
20
  describe('Policy API', function() {
 
21
    var testCall, service;
 
22
    var apiService = {};
 
23
    var toastService = {};
 
24
 
 
25
    beforeEach(
 
26
      module('horizon.mock.openstack-service-api',
 
27
             function($provide, initServices) {
 
28
               testCall = initServices($provide, apiService, toastService);
 
29
             })
 
30
    );
 
31
 
 
32
    beforeEach(module('horizon.app.core.openstack-service-api'));
 
33
 
 
34
    beforeEach(inject(['horizon.app.core.openstack-service-api.policy', function(policyAPI) {
 
35
      service = policyAPI;
 
36
    }]));
 
37
 
 
38
    it('defines the service', function() {
 
39
      expect(service).toBeDefined();
 
40
    });
 
41
 
 
42
    var tests = [
 
43
      {
 
44
        "func": "check",
 
45
        "method": "post",
 
46
        "path": "/api/policy/",
 
47
        "data": "rules",
 
48
        "error": "Policy check failed.",
 
49
        "testInput": [
 
50
          "rules"
 
51
        ],
 
52
        "messageType": "warning"
 
53
      }
 
54
    ];
 
55
 
 
56
    // Iterate through the defined tests and apply as Jasmine specs.
 
57
    angular.forEach(tests, function(params) {
 
58
      it('defines the ' + params.func + ' call properly', function() {
 
59
        var callParams = [apiService, service, toastService, params];
 
60
        testCall.apply(this, callParams);
 
61
      });
 
62
    });
 
63
 
 
64
  });
 
65
 
 
66
})();