alert_instances_controller_test.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var controller;
  20. describe('App.MainAlertDefinitionActionsController', function () {
  21. beforeEach(function () {
  22. controller = App.MainAlertInstancesController.create({});
  23. });
  24. describe('#fetchAlertInstances', function () {
  25. describe('loading instances from correct endpoint', function () {
  26. beforeEach(function () {
  27. sinon.stub(App.ajax, 'send', Em.K);
  28. });
  29. afterEach(function () {
  30. App.ajax.send.restore();
  31. });
  32. it('should load by Host name', function () {
  33. controller.loadAlertInstancesByHost('host');
  34. console.log(App.ajax.send.args[0]);
  35. expect(App.ajax.send.args[0][0].name).to.equal('alerts.instances.by_host');
  36. });
  37. it('should load by AlertDefinition id', function () {
  38. controller.loadAlertInstancesByAlertDefinition('1');
  39. console.log(App.ajax.send.args[0]);
  40. expect(App.ajax.send.args[0][0].name).to.equal('alerts.instances.by_definition');
  41. });
  42. it('should load all', function () {
  43. controller.loadAlertInstances();
  44. console.log(App.ajax.send.args[0]);
  45. expect(App.ajax.send.args[0][0].name).to.equal('alerts.instances');
  46. });
  47. });
  48. });
  49. });