hosts_mapper_test.js 2.1 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 Ember = require('ember');
  19. var App = require('app');
  20. require('models/host');
  21. require('models/host_component');
  22. require('mappers/server_data_mapper');
  23. require('mappers/hosts_mapper');
  24. describe('App.hostsMapper', function () {
  25. describe('#sortByPublicHostName()', function () {
  26. var tests = [
  27. {
  28. i: [
  29. {public_host_name: 'host0'},
  30. {public_host_name: 'host1'},
  31. {public_host_name: 'host2'},
  32. {public_host_name: 'host3'}
  33. ],
  34. m: 'Sorted array',
  35. e: ['host0','host1','host2','host3']
  36. },
  37. {
  38. i: [
  39. {public_host_name: 'host3'},
  40. {public_host_name: 'host2'},
  41. {public_host_name: 'host1'},
  42. {public_host_name: 'host0'}
  43. ],
  44. m: 'Reverse sorted array',
  45. e: ['host0','host1','host2','host3']
  46. },
  47. {
  48. i: [
  49. {public_host_name: 'host2'},
  50. {public_host_name: 'host3'},
  51. {public_host_name: 'host0'},
  52. {public_host_name: 'host1'}
  53. ],
  54. m: 'Shuffled array',
  55. e: ['host0','host1','host2','host3']
  56. }
  57. ];
  58. tests.forEach(function(test) {
  59. it(test.m, function() {
  60. expect(App.hostsMapper.sortByPublicHostName(test.i).mapProperty('public_host_name')).to.eql(test.e);
  61. });
  62. });
  63. });
  64. });