experimental_test.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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('views/experimental');
  20. var view,
  21. transition,
  22. supports = {},
  23. transitionStubbed = false,
  24. viewSupports = [
  25. Em.Object.create({
  26. name: 'sup0',
  27. selected: true
  28. }),
  29. Em.Object.create({
  30. name: 'sup1',
  31. selected: false
  32. })
  33. ],
  34. saveObject = {};
  35. describe('App.ExperimentalView', function () {
  36. before(function () {
  37. viewSupports.forEach(function(item) {
  38. supports[item.get('name')] = item.get('selected');
  39. });
  40. sinon.stub(App, 'get', function(k) {
  41. if (k === 'supports') return supports;
  42. return Em.get(App, k);
  43. });
  44. });
  45. beforeEach(function () {
  46. view = App.ExperimentalView.create();
  47. });
  48. after(function () {
  49. App.get.restore();
  50. });
  51. describe('#supports', function () {
  52. it('should take data from App.supports', function () {
  53. expect(view.get('supports')).to.eql(viewSupports);
  54. });
  55. });
  56. describe('#doSave', function () {
  57. before(function () {
  58. sinon.stub(Ember, 'set', function (p, v) {
  59. if (p.indexOf('App.supports.' != -1)) {
  60. p = p.replace('App.supports.', '');
  61. saveObject[p] = v;
  62. return;
  63. }
  64. return Ember.set(p, v);
  65. });
  66. sinon.stub(App.router, 'transitionTo', Em.K);
  67. });
  68. after(function () {
  69. Em.set.restore();
  70. App.router.transitionTo.restore();
  71. });
  72. it('should pass data to App.supports', function () {
  73. view.set('supports', viewSupports);
  74. view.doSave();
  75. expect(saveObject).to.eql(supports);
  76. });
  77. });
  78. });