step2_test.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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 Ember = require('ember');
  20. require('controllers/wizard/step2_controller');
  21. require('models/host');
  22. require('models/host_component');
  23. require('messages');
  24. var c;
  25. describe('App.WizardStep2Controller', function () {
  26. var userErrorTests = Em.A([
  27. {
  28. manualInstall: false,
  29. user: '',
  30. e: ''
  31. },
  32. {
  33. manualInstall: true,
  34. user: '',
  35. e: null
  36. },
  37. {
  38. manualInstall: true,
  39. user: 'nobody',
  40. e: null
  41. },
  42. {
  43. manualInstall: false,
  44. user: 'nobody',
  45. e: null
  46. }
  47. ]);
  48. beforeEach(function() {
  49. c = App.WizardStep2Controller.create();
  50. });
  51. describe('#isInstaller', function() {
  52. it('true if controllerName is installerController', function() {
  53. var controller = App.WizardStep2Controller.create({content: {controllerName: 'installerController'}});
  54. expect(controller.get('isInstaller')).to.equal(true);
  55. });
  56. it('false if controllerName isn\'t installerController', function() {
  57. var controller = App.WizardStep2Controller.create({content: {controllerName: 'addServiceController'}});
  58. expect(controller.get('isInstaller')).to.equal(false);
  59. });
  60. });
  61. describe('#manualInstall', function() {
  62. it('should be equal to content.installOptions.manualInstall', function() {
  63. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: true}}});
  64. expect(controller.get('manualInstall')).to.equal(true);
  65. controller.toggleProperty('content.installOptions.manualInstall');
  66. expect(controller.get('manualInstall')).to.equal(false);
  67. });
  68. });
  69. describe('#hostNames', function() {
  70. it('should be equal to content.installOptions.hostNames', function() {
  71. var controller = App.WizardStep2Controller.create({content: {installOptions: {hostNames: 'A,b,C'}}});
  72. expect(controller.get('hostNames')).to.equal('a,b,c');
  73. controller.set('content.installOptions.hostNames', 'a,B');
  74. expect(controller.get('hostNames')).to.equal('a,b');
  75. });
  76. });
  77. describe('#sshKey', function() {
  78. it('should be equal to content.installOptions.sshKey', function() {
  79. var controller = App.WizardStep2Controller.create({content: {installOptions: {sshKey: '123'}}});
  80. expect(controller.get('sshKey')).to.equal('123');
  81. controller.set('content.installOptions.sshKey', '321');
  82. expect(controller.get('sshKey')).to.equal('321');
  83. });
  84. });
  85. describe('#sshUser', function() {
  86. it('should be equal to content.installOptions.sshUser', function() {
  87. var controller = App.WizardStep2Controller.create({content: {installOptions: {sshUser: '123'}}});
  88. expect(controller.get('sshUser')).to.equal('123');
  89. controller.set('content.installOptions.sshUser', '321');
  90. expect(controller.get('sshUser')).to.equal('321');
  91. });
  92. });
  93. describe('#agentUser', function() {
  94. it('should be equal to content.installOptions.agentUser', function() {
  95. var controller = App.WizardStep2Controller.create({content: {installOptions: {agentUser: '123'}}});
  96. expect(controller.get('agentUser')).to.equal('123');
  97. controller.set('content.installOptions.agentUser', '321');
  98. expect(controller.get('agentUser')).to.equal('321');
  99. });
  100. });
  101. describe('#installType', function() {
  102. it('should be manualDriven if manualInstall is selected', function() {
  103. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: true}}});
  104. expect(controller.get('installType')).to.equal('manualDriven');
  105. });
  106. it('should be ambariDriven if manualInstall isn\'t selected', function() {
  107. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: false}}});
  108. expect(controller.get('installType')).to.equal('ambariDriven');
  109. });
  110. });
  111. describe('#updateHostNameArr()', function () {
  112. var controller = App.WizardStep2Controller.create({
  113. hostNames: 'apache.ambari'
  114. });
  115. controller.updateHostNameArr();
  116. it('should push to hostNameArr only new host names', function(){
  117. expect(controller.get('hostNameArr').length).to.equal(1);
  118. });
  119. it('should push to inputtedAgainHostNames already installed host names', function(){
  120. expect(controller.get('inputtedAgainHostNames').length).to.equal(0);
  121. })
  122. });
  123. describe('#isAllHostNamesValid()', function () {
  124. var controller = App.WizardStep2Controller.create({
  125. hostNames: ''
  126. });
  127. it('should return true if all host names are valid', function(){
  128. controller.set('hostNames', 'amache.org ambari.com');
  129. expect(controller.isAllHostNamesValid()).to.equal(true);
  130. });
  131. var tests = Em.A([
  132. 'hostname',
  133. '-hostname.com',
  134. 'hostname-.com',
  135. 'host_name.com',
  136. '123.123.123.123',
  137. 'hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname.hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname.hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname.hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname',
  138. 'hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname.hostname'
  139. ]);
  140. tests.forEach(function (test) {
  141. it('should return false for invalid host names ' + test + ' ', function () {
  142. controller.set('hostNames', test);
  143. expect(controller.isAllHostNamesValid()).to.equal(false);
  144. });
  145. });
  146. });
  147. describe('#checkHostError()', function () {
  148. var controller = App.WizardStep2Controller.create();
  149. it('should set hostsError if hostNames is ""', function () {
  150. controller.set('content', {'installOptions': {'hostNames': ''}});
  151. controller.checkHostError();
  152. expect(controller.get('hostsError').length).to.be.above(2);
  153. });
  154. it('should set hostsError to null if hostNames is valid', function () {
  155. controller.set('content', {'installOptions': {'hostNames': 'ambari'}});
  156. controller.checkHostError();
  157. expect(controller.get('hostsError')).to.equal(null);
  158. })
  159. });
  160. describe('#checkHostAfterSubmitHandler()', function () {
  161. it('should be called after changing hasSubmitted', function (done) {
  162. var controller = App.WizardStep2Controller.create({
  163. checkHostError: function () {
  164. done();
  165. }
  166. });
  167. controller.set('hasSubmitted', true);
  168. });
  169. it('should be called after changing hostNames', function (done) {
  170. var controller = App.WizardStep2Controller.create({
  171. hasSubmitted: true,
  172. checkHostError: function () {
  173. done();
  174. }
  175. });
  176. controller.set('content', {'installOptions': {'hostNames': 'ambari'}});
  177. })
  178. });
  179. describe('#sshKeyError', function () {
  180. var tests = Em.A([
  181. {
  182. manualInstall: false,
  183. sshKey: '',
  184. hasSubmitted: false,
  185. e: null
  186. },
  187. {
  188. manualInstall: true,
  189. sshKey: '',
  190. hasSubmitted: false,
  191. e: null
  192. },
  193. {
  194. manualInstall: true,
  195. sshKey: 'nobody',
  196. hasSubmitted: false,
  197. e: null
  198. },
  199. {
  200. manualInstall: false,
  201. sshKey: 'nobody',
  202. hasSubmitted: false,
  203. e: null
  204. },
  205. {
  206. manualInstall: false,
  207. sshKey: '',
  208. hasSubmitted: true,
  209. e: null
  210. },
  211. {
  212. manualInstall: true,
  213. sshKey: '',
  214. hasSubmitted: true,
  215. e: null
  216. },
  217. {
  218. manualInstall: true,
  219. sshKey: 'nobody',
  220. hasSubmitted: true,
  221. e: null
  222. },
  223. {
  224. manualInstall: false,
  225. sshKey: 'nobody',
  226. hasSubmitted: true,
  227. e: null
  228. }
  229. ]);
  230. tests.forEach(function(test) {
  231. it(test.sshKey + ' ' + test.manualInstall.toString() + ' ' + test.hasSubmitted.toString(), function() {
  232. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, sshKey: test.sshKey}}});
  233. if(Em.isNone(test.e)) {
  234. expect(controller.get('sshKeyError')).to.equal(null);
  235. }
  236. else {
  237. expect(controller.get('sshKeyError').length).to.be.above(2);
  238. }
  239. });
  240. });
  241. });
  242. describe('#sshUserError', function () {
  243. userErrorTests.forEach(function(test) {
  244. it('', function() {
  245. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, sshUser: test.user}}});
  246. if(Em.isNone(test.e)) {
  247. expect(controller.get('sshUserError')).to.equal(null);
  248. }
  249. else {
  250. expect(controller.get('sshUserError').length).to.be.above(2);
  251. }
  252. });
  253. });
  254. });
  255. describe('#agentUserError', function () {
  256. afterEach(function () {
  257. App.get.restore();
  258. });
  259. userErrorTests.forEach(function(test) {
  260. it('Ambari Agent user account customize enabled', function() {
  261. sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(true);
  262. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, agentUser: test.user}}});
  263. if(Em.isNone(test.e)) {
  264. expect(controller.get('agentUserError')).to.be.null;
  265. }
  266. else {
  267. expect(controller.get('agentUserError').length).to.be.above(2);
  268. }
  269. });
  270. });
  271. userErrorTests.forEach(function(test) {
  272. it('Ambari Agent user account customize disabled', function() {
  273. sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(false);
  274. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, agentUser: test.user}}});
  275. expect(controller.get('agentUserError')).to.be.null;
  276. });
  277. });
  278. });
  279. describe('#getHostInfo()', function () {
  280. it('should return object with bootStatus, installType and name for every element in hostNameArr', function () {
  281. var controller = App.WizardStep2Controller.create({
  282. hostNameArr: ['apache', 'ambari'],
  283. installType: 'manualDriven'
  284. });
  285. var test = controller.getHostInfo();
  286. expect(test).to.eql({
  287. 'apache':{'name':'apache', 'installType': 'manualDriven', 'bootStatus': 'PENDING', isInstalled: false},
  288. 'ambari':{'name':'ambari', 'installType': 'manualDriven', 'bootStatus': 'PENDING', isInstalled: false}
  289. });
  290. })
  291. });
  292. describe('#setSshKey()', function () {
  293. it('should set content.installOptions.sshKey', function () {
  294. var controller = App.WizardStep2Controller.create({
  295. content: {'installOptions': {'sshKey': '111'}}
  296. });
  297. controller.setSshKey('222');
  298. expect(controller.get('content.installOptions.sshKey')).to.equal('222');
  299. })
  300. });
  301. describe('#evaluateStep()', function () {
  302. it('should return false if isSubmitDisabled is true', function () {
  303. var controller = App.WizardStep2Controller.create({
  304. hostNames: 'apache.ambari',
  305. parseHostNamesAsPatternExpression: Em.K
  306. });
  307. controller.reopen({isSubmitDisabled: true});
  308. expect(controller.evaluateStep()).to.equal(false);
  309. });
  310. it('should return false if hostsError is not empty', function () {
  311. var controller = App.WizardStep2Controller.create({
  312. hostNames: 'apache.ambari',
  313. parseHostNamesAsPatternExpression: Em.K
  314. });
  315. controller.set('hostsError', 'error');
  316. expect(controller.evaluateStep()).to.equal(false);
  317. });
  318. it('should return false if sshKeyError is not empty', function () {
  319. var controller = App.WizardStep2Controller.create({
  320. hostNames: 'apache.ambari',
  321. parseHostNamesAsPatternExpression: Em.K
  322. });
  323. controller.reopen({sshKeyError: 'error'});
  324. expect(controller.evaluateStep()).to.equal(false);
  325. });
  326. it('should return false if sshUserError is not empty', function () {
  327. var controller = App.WizardStep2Controller.create({
  328. hostNames: 'apache.ambari',
  329. parseHostNamesAsPatternExpression: Em.K
  330. });
  331. controller.reopen({sshUserError: 'error'});
  332. expect(controller.evaluateStep()).to.equal(false);
  333. });
  334. it('should return false if agentUserError is not empty', function () {
  335. var controller = App.WizardStep2Controller.create({
  336. hostNames: 'apache.ambari',
  337. parseHostNamesAsPatternExpression: Em.K
  338. });
  339. controller.reopen({agentUserError: 'error'});
  340. expect(controller.evaluateStep()).to.equal(false);
  341. });
  342. it('should return false if hostNameArr is empty', function () {
  343. var controller = App.WizardStep2Controller.create({
  344. hostNames: '',
  345. parseHostNamesAsPatternExpression: Em.K
  346. });
  347. expect(controller.evaluateStep()).to.equal(false);
  348. });
  349. it('should return false if isPattern is true', function () {
  350. var controller = App.WizardStep2Controller.create({
  351. hostNames: 'apache.ambari',
  352. isPattern: true,
  353. parseHostNamesAsPatternExpression: Em.K
  354. });
  355. expect(controller.evaluateStep()).to.equal(false);
  356. })
  357. });
  358. describe('#parseHostNamesAsPatternExpression()', function () {
  359. it('should parse hosts from pattern expression to hostNameArr', function () {
  360. var controller = App.WizardStep2Controller.create({
  361. hostNameArr: ['host[001-011]']
  362. });
  363. controller.parseHostNamesAsPatternExpression();
  364. var result = true;
  365. var hosts = controller.get('hostNameArr');
  366. for (var i = 1; i<12; i++) {
  367. var extra = (i.toString().length == 1) ? 0 : '';
  368. if (hosts[i-1] !== 'host0' + extra + i) {
  369. result = false;
  370. }
  371. }
  372. expect(result).to.equal(true);
  373. })
  374. });
  375. describe('#proceedNext()', function () {
  376. it('should call warningPopup if not isAllHostNamesValid and no warningConfirmed', function() {
  377. c.reopen({
  378. isAllHostNamesValid: function() {
  379. return false;
  380. },
  381. warningPopup: Em.K
  382. });
  383. sinon.spy(c, 'warningPopup');
  384. var r = c.proceedNext(false);
  385. expect(r).to.equal(false);
  386. expect(c.warningPopup.calledOnce).to.equal(true);
  387. });
  388. it('should call manualInstallPopup if manualInstall is true', function () {
  389. c.reopen({
  390. hostNames: '',
  391. manualInstall: true,
  392. manualInstallPopup: Em.K
  393. });
  394. sinon.spy(c, 'manualInstallPopup');
  395. var r = c.proceedNext(true);
  396. expect(r).to.equal(false);
  397. expect(c.manualInstallPopup.calledOnce).to.equal(true);
  398. });
  399. it ('should save hosts and proceed next if manualInstall is false', function() {
  400. sinon.stub(App.router, 'send', Em.K);
  401. c.reopen({
  402. hostNameArr: ['h1'],
  403. manualInstall: false,
  404. isAllHostNamesValid: function() {return true;},
  405. content: {
  406. installOptions: {},
  407. hosts: null
  408. }
  409. });
  410. var r = c.proceedNext();
  411. expect(r).to.equal(true);
  412. expect(Em.keys(c.get('content.hosts'))).to.eql(['h1']);
  413. expect(App.router.send.calledWith('next')).to.equal(true);
  414. App.router.send.restore();
  415. });
  416. });
  417. describe('#isSubmitDisabled', function () {
  418. var controller = App.WizardStep2Controller.create({
  419. hostsError: '',
  420. sshKeyError: '',
  421. sshUserError: '',
  422. agentUserError: ''
  423. });
  424. it('should return value if hostsError is not empty', function () {
  425. controller.set('hostsError', 'error');
  426. expect(controller.get('isSubmitDisabled').length).to.above(0);
  427. });
  428. it('should return value if sshKeyError is not empty', function () {
  429. controller.set('sshKeyError', 'error');
  430. controller.set('hostsError', '');
  431. expect(controller.get('isSubmitDisabled').length).to.above(0);
  432. });
  433. it('should return value if sshUserError is not empty', function () {
  434. controller.set('sshUserError', 'error');
  435. controller.set('sshKeyError', '');
  436. expect(controller.get('isSubmitDisabled').length).to.above(0);
  437. });
  438. it('should return value if agentUserError is not empty', function () {
  439. controller.set('agentUserError', 'error');
  440. controller.set('sshUserError', '');
  441. expect(controller.get('isSubmitDisabled').length).to.above(0);
  442. });
  443. });
  444. describe('#installedHostsPopup', function() {
  445. beforeEach(function() {
  446. sinon.spy(App.ModalPopup, 'show');
  447. sinon.stub(c, 'proceedNext', Em.K);
  448. });
  449. afterEach(function() {
  450. App.ModalPopup.show.restore();
  451. c.proceedNext.restore();
  452. });
  453. it('should call App.ModalPopup.show', function() {
  454. c.installedHostsPopup();
  455. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  456. });
  457. it('should proceed next on primary', function() {
  458. c.installedHostsPopup().onPrimary();
  459. expect(c.proceedNext.calledOnce).to.equal(true);
  460. });
  461. });
  462. describe('#warningPopup', function() {
  463. beforeEach(function() {
  464. sinon.spy(App.ModalPopup, 'show');
  465. sinon.stub(c, 'proceedNext', Em.K);
  466. });
  467. afterEach(function() {
  468. App.ModalPopup.show.restore();
  469. c.proceedNext.restore();
  470. });
  471. it('should call App.ModalPopup.show', function() {
  472. c.warningPopup();
  473. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  474. });
  475. it('should proceed next on primary', function() {
  476. c.warningPopup().onPrimary();
  477. expect(c.proceedNext.calledWith(true)).to.equal(true);
  478. });
  479. });
  480. describe('#hostNamePatternPopup', function() {
  481. beforeEach(function() {
  482. sinon.spy(App.ModalPopup, 'show');
  483. sinon.stub(c, 'proceedNext', Em.K);
  484. });
  485. afterEach(function() {
  486. App.ModalPopup.show.restore();
  487. c.proceedNext.restore();
  488. });
  489. it('should call App.ModalPopup.show', function() {
  490. c.hostNamePatternPopup();
  491. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  492. });
  493. it('should proceed next on primary', function() {
  494. c.hostNamePatternPopup().onPrimary();
  495. expect(c.proceedNext.calledOnce).to.equal(true);
  496. });
  497. });
  498. describe('#manualInstallPopup', function() {
  499. beforeEach(function() {
  500. sinon.spy(App.ModalPopup, 'show');
  501. sinon.stub(App.router, 'send', Em.K);
  502. sinon.stub(c, 'saveHosts', Em.K);
  503. });
  504. afterEach(function() {
  505. App.ModalPopup.show.restore();
  506. App.router.send.restore();
  507. c.saveHosts.restore();
  508. });
  509. it('should call App.ModalPopup.show', function() {
  510. c.manualInstallPopup();
  511. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  512. });
  513. it('should save hosts and go next on primary', function() {
  514. c.manualInstallPopup().onPrimary();
  515. expect(c.saveHosts.calledOnce).to.equal(true);
  516. expect(App.router.send.calledWith('next')).to.equal(true);
  517. });
  518. });
  519. describe('#manualInstallWarningPopup', function() {
  520. beforeEach(function() {
  521. sinon.spy(App.ModalPopup, 'show');
  522. });
  523. afterEach(function() {
  524. App.ModalPopup.show.restore();
  525. });
  526. it('should call App.ModalPopup.show if content.installOptions.useSsh is false', function() {
  527. var controller = App.WizardStep2Controller.create({content: {installOptions: {useSsh: false}}});
  528. controller.manualInstallWarningPopup();
  529. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  530. });
  531. it('shouldn\'t call App.ModalPopup.show if content.installOptions.useSsh is true', function() {
  532. var controller = App.WizardStep2Controller.create({content: {installOptions: {useSsh: true}}});
  533. controller.manualInstallWarningPopup();
  534. expect(App.ModalPopup.show.called).to.equal(false);
  535. });
  536. });
  537. describe('#setAmbariJavaHome', function() {
  538. beforeEach(function() {
  539. sinon.spy($, 'ajax');
  540. });
  541. afterEach(function() {
  542. $.ajax.restore();
  543. });
  544. it('should do ajax-request', function() {
  545. var controller = App.WizardStep2Controller.create({onGetAmbariJavaHomeSuccess: Em.K, onGetAmbariJavaHomeError: Em.K});
  546. controller.setAmbariJavaHome();
  547. expect($.ajax.calledOnce).to.equal(true);
  548. });
  549. });
  550. describe('#onGetAmbariJavaHomeSuccess', function() {
  551. it('should set java.home value receiced from server', function() {
  552. var controller = App.WizardStep2Controller.create({content: {installOptions: {}}});
  553. var test = {RootServiceComponents: {properties: {'java.home': '/root'}}};
  554. controller.onGetAmbariJavaHomeSuccess(test);
  555. expect(controller.content.installOptions.javaHome).to.equal('/root');
  556. });
  557. });
  558. describe('#onGetAmbariJavaHomeError', function() {
  559. it('should set default java.home value', function() {
  560. var controller = App.WizardStep2Controller.create({content: {installOptions: {}}});
  561. controller.onGetAmbariJavaHomeError();
  562. expect(controller.content.installOptions.javaHome).to.equal(App.get('defaultJavaHome'));
  563. });
  564. });
  565. describe('#saveHosts', function() {
  566. beforeEach(function() {
  567. sinon.stub(c, 'setAmbariJavaHome', Em.K);
  568. c.reopen({
  569. hostNameArr: ['h1'],
  570. content: {
  571. hosts: null
  572. }
  573. });
  574. });
  575. afterEach(function() {
  576. c.setAmbariJavaHome.restore();
  577. });
  578. it('should call setAmbariJavaHome', function() {
  579. c.saveHosts();
  580. expect(c.setAmbariJavaHome.calledOnce).to.equal(true);
  581. });
  582. it('should set content.hosts', function() {
  583. c.saveHosts();
  584. expect(Em.keys(c.get('content.hosts'))).to.eql(['h1']);
  585. });
  586. });
  587. });