jobs_mapper_test.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 Ember = require('ember');
  19. var App = require('app');
  20. require('views/main/apps/item/dag_view');
  21. require('mappers/server_data_mapper');
  22. require('mappers/jobs_mapper');
  23. describe('App.jobTimeLineMapper', function () {
  24. var test_input = {
  25. "map": [
  26. {
  27. "x": 1369394950,
  28. "y": 0
  29. },
  30. {
  31. "x": 1369394951,
  32. "y": 1
  33. },
  34. {
  35. "x": 1369394952,
  36. "y": 1
  37. },
  38. {
  39. "x": 1369394953,
  40. "y": 0
  41. }
  42. ],
  43. "shuffle": [
  44. {
  45. "x": 1369394950,
  46. "y": 0
  47. },
  48. {
  49. "x": 1369394951,
  50. "y": 0
  51. },
  52. {
  53. "x": 1369394952,
  54. "y": 1
  55. },
  56. {
  57. "x": 1369394953,
  58. "y": 1
  59. }
  60. ],
  61. "reduce": [
  62. {
  63. "x": 1369394950,
  64. "y": 0
  65. },
  66. {
  67. "x": 1369394951,
  68. "y": 0
  69. },
  70. {
  71. "x": 1369394952,
  72. "y": 0
  73. },
  74. {
  75. "x": 1369394953,
  76. "y": 0
  77. }
  78. ]
  79. };
  80. describe('#coordinatesModify()', function () {
  81. it('map', function() {
  82. var new_map = App.jobTimeLineMapper.coordinatesModify(test_input.map);
  83. expect(new_map.length).to.equal(6);
  84. expect(new_map[1].y).to.equal(new_map[0].y);
  85. expect(new_map[2].x).to.equal(new_map[1].x);
  86. expect(new_map[4].y).to.equal(new_map[5].y);
  87. expect(new_map[3].x).to.equal(new_map[4].x);
  88. });
  89. it('shuffle', function() {
  90. var new_shuffle = App.jobTimeLineMapper.coordinatesModify(test_input.shuffle);
  91. expect(new_shuffle.length).to.equal(6);
  92. expect(new_shuffle[2].y).to.equal(new_shuffle[1].y);
  93. expect(new_shuffle[3].x).to.equal(new_shuffle[2].x);
  94. expect(new_shuffle[3].y).to.equal(new_shuffle[4].y);
  95. expect(new_shuffle[4].x).to.equal(new_shuffle[5].x);
  96. });
  97. it('reduce', function() {
  98. var new_reduce = App.jobTimeLineMapper.coordinatesModify(test_input.reduce);
  99. expect(new_reduce.length).to.equal(4);
  100. });
  101. });
  102. });