root_service_test.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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('models/root_service');
  20. var roleMock = function (str, flag) {
  21. return flag ? str.toLowerCase() : str.toCapital();
  22. };
  23. describe('App.RootService', function () {
  24. var rootService;
  25. beforeEach(function () {
  26. rootService = App.RootService.createRecord();
  27. });
  28. describe('#displayName', function () {
  29. beforeEach(function () {
  30. sinon.stub(App.format, 'role', roleMock);
  31. });
  32. afterEach(function () {
  33. App.format.role.restore();
  34. });
  35. it('should format service name', function () {
  36. rootService.set('serviceName', 'HDFS');
  37. expect(rootService.get('displayName')).to.equal('hdfs');
  38. });
  39. });
  40. });
  41. describe('App.RootServiceComponents', function () {
  42. var rootServiceComponents;
  43. beforeEach(function () {
  44. rootServiceComponents = App.RootServiceComponents.createRecord();
  45. });
  46. describe('#displayName', function () {
  47. beforeEach(function () {
  48. sinon.stub(App.format, 'role', roleMock);
  49. });
  50. afterEach(function () {
  51. App.format.role.restore();
  52. });
  53. it('should format component name', function () {
  54. rootServiceComponents.set('componentName', 'DATANODE');
  55. expect(rootServiceComponents.get('displayName')).to.equal('Datanode');
  56. });
  57. });
  58. });