storm_linear_time_test.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. require('mixins/common/chart/storm_linear_time');
  20. var slt,
  21. template,
  22. series,
  23. jsonDataFalse = {
  24. metrics: {
  25. id: 'metrics'
  26. }
  27. },
  28. jsonDataTrue = {
  29. metrics: {
  30. storm: {
  31. nimbus: {
  32. name: 'nimbus'
  33. }
  34. }
  35. }
  36. };
  37. describe('App.StormLinearTimeChartMixin', function () {
  38. beforeEach(function () {
  39. slt = Em.Object.create(App.StormLinearTimeChartMixin, {
  40. stormChartDefinition: [
  41. {
  42. field: 'name',
  43. name: 'nimbus'
  44. }
  45. ]
  46. });
  47. });
  48. describe('#getDataForAjaxRequest', function () {
  49. it('should take data from stormChartDefinition', function () {
  50. template = slt.getDataForAjaxRequest().metricsTemplate;
  51. expect(template).to.contain('metrics');
  52. expect(template).to.contain('storm');
  53. expect(template).to.contain('nimbus');
  54. });
  55. });
  56. describe('#transformToSeries', function () {
  57. it('should be empty', function () {
  58. expect(slt.transformToSeries(jsonDataFalse)).to.be.empty;
  59. });
  60. it('should take one element from data', function () {
  61. slt.set('transformData', function (data, name) {
  62. return name + ': ' + JSON.stringify(data);
  63. });
  64. series = slt.transformToSeries(jsonDataTrue);
  65. expect(series).to.have.length(1);
  66. expect(series[0]).to.equal('nimbus: "nimbus"');
  67. });
  68. });
  69. });