experimental_test.js 2.4 KB

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