repository_version_test.js 2.5 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 App = require('app');
  19. var model;
  20. function getModel() {
  21. return App.RepositoryVersion.createRecord();
  22. }
  23. describe('App.RepositoryVersion', function () {
  24. beforeEach(function () {
  25. model = getModel();
  26. });
  27. App.TestAliases.testAsComputedFirstNotBlank(getModel(), 'status', ['stackVersion.state', 'defaultStatus']);
  28. App.TestAliases.testAsComputedIfThenElse(getModel(), 'noInitHostsTooltip', 'noInitHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip'));
  29. App.TestAliases.testAsComputedIfThenElse(getModel(), 'noCurrentHostsTooltip', 'noCurrentHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip'));
  30. App.TestAliases.testAsComputedIfThenElse(getModel(), 'noInstalledHostsTooltip', 'noInstalledHosts', Em.I18n.t('admin.stackVersions.version.emptyHostsTooltip'), Em.I18n.t('admin.stackVersions.version.hostsTooltip'));
  31. describe("#notInstalledHosts", function() {
  32. before(function () {
  33. sinon.stub(App, 'get').returns(['host1']);
  34. });
  35. beforeEach(function () {
  36. model = getModel();
  37. });
  38. after(function () {
  39. App.get.restore();
  40. });
  41. it("stackVersion is null", function() {
  42. model.set('stackVersion', null);
  43. model.propertyDidChange('notInstalledHosts');
  44. expect(model.get('notInstalledHosts')).to.eql(['host1']);
  45. });
  46. it("stackVersion has notInstalledHosts array", function() {
  47. model.set('stackVersion', Em.Object.create({
  48. notInstalledHosts: ['host2']
  49. }));
  50. model.propertyDidChange('notInstalledHosts');
  51. expect(model.get('notInstalledHosts')).to.eql(['host2']);
  52. });
  53. });
  54. });