stack_versions_view_test.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. describe('App.MainHostStackVersionsView', function() {
  20. var view = App.MainHostStackVersionsView.create({
  21. filteredCount: 0,
  22. totalCount: 0
  23. });
  24. describe("#host", function () {
  25. before(function () {
  26. sinon.stub(App.router, 'get').returns(Em.Object.create({
  27. id: 1
  28. }));
  29. sinon.stub(view, 'filter').returns([Em.Object.create({
  30. id: 1
  31. })]);
  32. });
  33. after(function () {
  34. App.router.get.restore();
  35. view.filter.restore();
  36. });
  37. it("", function () {
  38. view.propertyDidChange('host');
  39. expect(view.get('host')).to.eql(Em.Object.create({
  40. id: 1
  41. }));
  42. });
  43. });
  44. describe("#content", function () {
  45. before(function () {
  46. sinon.stub(view, 'get').returns([Em.Object.create({
  47. id: 1
  48. })]);
  49. sinon.stub(view, 'filter').returns([Em.Object.create({
  50. id: 1
  51. })]);
  52. });
  53. after(function () {
  54. view.get.restore();
  55. view.filter.restore();
  56. });
  57. it("", function () {
  58. view.propertyDidChange('content');
  59. expect(view.get('content')).to.eql([Em.Object.create({
  60. id: 1
  61. })]);
  62. });
  63. });
  64. describe("#filteredContentInfo", function () {
  65. it("", function () {
  66. view.set('filteredCount', 1);
  67. view.set('totalCount', 2);
  68. view.propertyDidChange('filteredContentInfo');
  69. expect(view.get('filteredContentInfo')).to.eql(Em.I18n.t('hosts.host.stackVersions.table.filteredInfo').format(1, 2));
  70. });
  71. });
  72. });