alert_instances_controller_test.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.MainAlertInstancesController', 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. expect(App.ajax.send.args[0][0].data.hostName).to.equal('host');
  37. });
  38. it('should load by AlertDefinition id', function () {
  39. controller.loadAlertInstancesByAlertDefinition('1');
  40. console.log(App.ajax.send.args[0]);
  41. expect(App.ajax.send.args[0][0].name).to.equal('alerts.instances.by_definition');
  42. expect(App.ajax.send.args[0][0].data.definitionId).to.equal('1');
  43. });
  44. it('should load all', function () {
  45. controller.loadAlertInstances();
  46. console.log(App.ajax.send.args[0]);
  47. expect(App.ajax.send.args[0][0].name).to.equal('alerts.instances');
  48. });
  49. });
  50. });
  51. });