dataset_mapper_test.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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('mappers/server_data_mapper');
  21. require('mappers/dataset_mapper');
  22. describe('App.dataSetMapper', function () {
  23. describe('#getId', function() {
  24. var tests = [
  25. {i:'My Name',e:'My_Name'},
  26. {i:'MyName',e:'MyName'},
  27. {i:'My Name',e:'My__Name'},
  28. {i:'My Big Name',e:'My_Big_Name'}
  29. ];
  30. it('Replace spaces with _', function() {
  31. tests.forEach(function(test) {
  32. expect(App.dataSetMapper.getId(test.i)).to.equal(test.e);
  33. });
  34. });
  35. });
  36. describe('#parseSchedule', function() {
  37. var tests = [
  38. {
  39. "Feeds":{
  40. "frequency":"minutes(1)",
  41. "timezone":"UTC",
  42. "clusters":{
  43. "cluster":[
  44. {
  45. "name":"drsource3",
  46. "type":"source",
  47. "validity":{
  48. "start":"2010-01-01T00:00Z",
  49. "end":"2015-01-01T02:00Z"
  50. }
  51. }
  52. ]
  53. }
  54. },
  55. "results": {
  56. start_time: '2:0:AM',
  57. end_time: '4:0:AM',
  58. frequency: 'minutes(1)',
  59. timezone: 'UTC',
  60. start_date: '1/5/2010',
  61. end_date: '1/4/2015'
  62. }
  63. },
  64. {
  65. "Feeds":{
  66. "frequency":"minutes(5)",
  67. "timezone":"UTC",
  68. "clusters":{
  69. "cluster":[
  70. {
  71. "name":"drsource3",
  72. "type":"source",
  73. "validity":{
  74. "start":"2013-01-01T15:00Z",
  75. "end":"2014-01-01T12:00Z"
  76. }
  77. }
  78. ]
  79. }
  80. },
  81. "results": {
  82. start_time: '5:0:PM',
  83. end_time: '2:0:PM',
  84. frequency: 'minutes(5)',
  85. timezone: 'UTC',
  86. start_date: '1/2/2013',
  87. end_date: '1/3/2014'
  88. }
  89. }
  90. ];
  91. tests.forEach(function(test) {
  92. it('parse valid data', function() {
  93. var schedule = App.dataSetMapper.parseSchedule(test);
  94. expect(schedule.start_time).to.equal(test.results.start_time);
  95. expect(schedule.end_time).to.equal(test.results.end_time);
  96. expect(schedule.frequency).to.equal(test.results.frequency);
  97. expect(schedule.timezone).to.equal(test.results.timezone);
  98. expect(schedule.start_date).to.equal(test.results.start_date);
  99. expect(schedule.end_date).to.equal(test.results.end_date);
  100. });
  101. });
  102. });
  103. });