controls_view_test.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  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/common/controls_view');
  20. describe('App.ServiceConfigRadioButtons', function () {
  21. describe('#didInsertElement', function () {
  22. var view = App.ServiceConfigRadioButtons.create({
  23. categoryConfigsAll: [],
  24. controller: Em.Object.create({
  25. wizardController: Em.Object.create({})
  26. }),
  27. serviceConfig: Em.Object.create({
  28. value: null
  29. })
  30. }),
  31. cases = [
  32. {
  33. wizardControllerName: 'addServiceController',
  34. serviceConfigValue: 'New MySQL Database',
  35. onOptionsChangeCalledTwice: true,
  36. handleDBConnectionPropertyCalledTwice: false,
  37. title: 'Add Service Wizard, New MySQL Database'
  38. },
  39. {
  40. wizardControllerName: 'addServiceController',
  41. serviceConfigValue: 'Existing MySQL Database',
  42. onOptionsChangeCalledTwice: false,
  43. handleDBConnectionPropertyCalledTwice: true,
  44. title: 'Add Service Wizard, Existing MySQL Database'
  45. },
  46. {
  47. wizardControllerName: 'installerController',
  48. serviceConfigValue: 'New MySQL Database',
  49. onOptionsChangeCalledTwice: true,
  50. handleDBConnectionPropertyCalledTwice: false,
  51. title: 'Install Wizard, New MySQL Database'
  52. },
  53. {
  54. wizardControllerName: 'installerController',
  55. serviceConfigValue: 'Existing MySQL Database',
  56. onOptionsChangeCalledTwice: false,
  57. handleDBConnectionPropertyCalledTwice: true,
  58. title: 'Install Wizard, Existing MySQL Database'
  59. },
  60. {
  61. wizardControllerName: null,
  62. serviceConfigValue: null,
  63. onOptionsChangeCalledTwice: false,
  64. handleDBConnectionPropertyCalledTwice: false,
  65. title: 'Service Configs Page'
  66. }
  67. ];
  68. beforeEach(function () {
  69. sinon.stub(view, 'onOptionsChange', Em.K);
  70. sinon.stub(view, 'handleDBConnectionProperty', Em.K);
  71. });
  72. afterEach(function () {
  73. view.onOptionsChange.restore();
  74. view.handleDBConnectionProperty.restore();
  75. });
  76. cases.forEach(function (item) {
  77. it(item.title, function () {
  78. view.set('controller.wizardController.name', item.wizardControllerName);
  79. view.set('serviceConfig.value', item.serviceConfigValue);
  80. view.didInsertElement();
  81. expect(view.onOptionsChange.calledTwice).to.equal(item.onOptionsChangeCalledTwice);
  82. expect(view.handleDBConnectionProperty.calledTwice).to.equal(item.handleDBConnectionPropertyCalledTwice);
  83. });
  84. });
  85. });
  86. describe('#databaseNameProperty', function () {
  87. var view = App.ServiceConfigRadioButtons.create({
  88. serviceConfig: Em.Object.create(),
  89. categoryConfigsAll: [
  90. {
  91. name: 'ambari.hive.db.schema.name',
  92. value: 'db0'
  93. },
  94. {
  95. name: 'oozie.db.schema.name',
  96. value: 'db2'
  97. }
  98. ]
  99. }),
  100. cases = [
  101. {
  102. serviceName: 'HIVE',
  103. value: 'db0'
  104. },
  105. {
  106. serviceName: 'OOZIE',
  107. value: 'db2'
  108. }
  109. ];
  110. cases.forEach(function (item) {
  111. it(item.serviceName, function () {
  112. view.set('serviceConfig.serviceName', item.serviceName);
  113. expect(view.get('databaseNameProperty.value')).to.equal(item.value);
  114. expect(view.get('databaseName')).to.equal(item.value);
  115. });
  116. });
  117. it('default case', function () {
  118. view.set('serviceConfig.serviceName', 'YARN');
  119. expect(view.get('databaseNameProperty')).to.be.null;
  120. expect(view.get('databaseName')).to.be.null;
  121. });
  122. });
  123. describe('#hostNameProperty', function () {
  124. var view = App.ServiceConfigRadioButtons.create({
  125. serviceConfig: Em.Object.create(),
  126. categoryConfigsAll: [
  127. {
  128. name: 'hive_ambari_host',
  129. value: 'h0'
  130. },
  131. {
  132. name: 'hive_existing_mysql_host',
  133. value: 'h1'
  134. },
  135. {
  136. name: 'hive_existing_postgresql_host',
  137. value: 'h2'
  138. },
  139. {
  140. name: 'hive_existing_oracle_host',
  141. value: 'h3'
  142. },
  143. {
  144. name: 'hive_existing_mssql_server_host',
  145. value: 'h4'
  146. },
  147. {
  148. name: 'hive_existing_mssql_server_2_host',
  149. value: 'h5'
  150. },
  151. {
  152. name: 'hive_hostname',
  153. value: 'h6'
  154. },
  155. {
  156. name: 'oozie_ambari_host',
  157. value: 'h10'
  158. },
  159. {
  160. name: 'oozie_existing_mysql_host',
  161. value: 'h11'
  162. },
  163. {
  164. name: 'oozie_existing_postgresql_host',
  165. value: 'h12'
  166. },
  167. {
  168. name: 'oozie_existing_oracle_host',
  169. value: 'h13'
  170. },
  171. {
  172. name: 'oozie_existing_mssql_server_host',
  173. value: 'h14'
  174. },
  175. {
  176. name: 'oozie_existing_mssql_server_2_host',
  177. value: 'h15'
  178. },
  179. {
  180. name: 'oozie_hostname',
  181. value: 'h16'
  182. }
  183. ]
  184. }),
  185. cases = [
  186. {
  187. serviceName: 'HIVE',
  188. value: 'New MySQL Database',
  189. expected: 'h0'
  190. },
  191. {
  192. serviceName: 'HIVE',
  193. value: 'Existing MySQL Database',
  194. expected: 'h1'
  195. },
  196. {
  197. serviceName: 'HIVE',
  198. value: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
  199. expected: 'h2'
  200. },
  201. {
  202. serviceName: 'HIVE',
  203. value: 'Existing Oracle Database',
  204. expected: 'h3'
  205. },
  206. {
  207. serviceName: 'HIVE',
  208. value: 'Existing MSSQL Server database with SQL authentication',
  209. expected: 'h4'
  210. },
  211. {
  212. serviceName: 'HIVE',
  213. value: 'Existing MSSQL Server database with integrated authentication',
  214. expected: 'h5'
  215. },
  216. {
  217. serviceName: 'HIVE',
  218. value: 'default case',
  219. expected: 'h6'
  220. },
  221. {
  222. serviceName: 'OOZIE',
  223. value: 'New Derby Database',
  224. expected: 'h10'
  225. },
  226. {
  227. serviceName: 'OOZIE',
  228. value: 'Existing MySQL Database',
  229. expected: 'h11'
  230. },
  231. {
  232. serviceName: 'OOZIE',
  233. value: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
  234. expected: 'h12'
  235. },
  236. {
  237. serviceName: 'OOZIE',
  238. value: 'Existing Oracle Database',
  239. expected: 'h13'
  240. },
  241. {
  242. serviceName: 'OOZIE',
  243. value: 'Existing MSSQL Server database with SQL authentication',
  244. expected: 'h14'
  245. },
  246. {
  247. serviceName: 'OOZIE',
  248. value: 'Existing MSSQL Server database with integrated authentication',
  249. expected: 'h15'
  250. },
  251. {
  252. serviceName: 'OOZIE',
  253. value: 'default case',
  254. expected: 'h16'
  255. }
  256. ];
  257. before(function () {
  258. sinon.stub(view, 'handleDBConnectionProperty', Em.K);
  259. });
  260. after(function () {
  261. view.handleDBConnectionProperty.restore();
  262. });
  263. cases.forEach(function (item) {
  264. it(item.serviceName + ', ' + item.value, function () {
  265. view.get('serviceConfig').setProperties({
  266. serviceName: item.serviceName,
  267. value: item.value
  268. });
  269. expect(view.get('hostNameProperty.value')).to.equal(item.expected);
  270. expect(view.get('hostName')).to.equal(item.expected);
  271. });
  272. });
  273. });
  274. describe('#onOptionsChange', function () {
  275. var view = App.ServiceConfigRadioButtons.create({
  276. hostName: null,
  277. databaseName: null,
  278. hostNameProperty: null,
  279. databaseNameProperty: null,
  280. connectionUrl: Em.Object.create(),
  281. dbClass: Em.Object.create(),
  282. serviceConfig: Em.Object.create(),
  283. categoryConfigsAll: [
  284. Em.Object.create({
  285. name: 'javax.jdo.option.ConnectionUserName'
  286. }),
  287. Em.Object.create({
  288. name: 'javax.jdo.option.ConnectionPassword'
  289. }),
  290. Em.Object.create({
  291. name: 'oozie.service.JPAService.jdbc.username'
  292. }),
  293. Em.Object.create({
  294. name: 'oozie.service.JPAService.jdbc.password'
  295. })
  296. ],
  297. parentView: Em.Object.create({
  298. serviceConfigs: [
  299. {
  300. name: 'hive_database_type',
  301. value: null
  302. }
  303. ]
  304. }),
  305. configs: [{}]
  306. }),
  307. cases = [
  308. {
  309. serviceName: 'HIVE',
  310. serviceConfigValue: 'New MySQL Database',
  311. databaseName: 'db0',
  312. hostName: 'h0',
  313. databaseNameDefault: 'db0d',
  314. hostNameDefault: 'h0d',
  315. connectionUrlValue: 'jdbc:mysql://h0/db0?createDatabaseIfNotExist=true',
  316. connectionUrlDefaultValue: 'jdbc:mysql://h0d/db0d?createDatabaseIfNotExist=true',
  317. dbClassValue: 'com.mysql.jdbc.Driver',
  318. isAuthVisibleAndRequired: true,
  319. hiveDbTypeValue: 'mysql'
  320. },
  321. {
  322. serviceName: 'HIVE',
  323. serviceConfigValue: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
  324. databaseName: 'db1',
  325. hostName: 'h1',
  326. databaseNameDefault: 'db1d',
  327. hostNameDefault: 'h1d',
  328. connectionUrlValue: 'jdbc:postgresql://h1:5432/db1',
  329. connectionUrlDefaultValue: 'jdbc:postgresql://h1d:5432/db1d',
  330. dbClassValue: 'org.postgresql.Driver',
  331. isAuthVisibleAndRequired: true,
  332. hiveDbTypeValue: 'postgres'
  333. },
  334. {
  335. serviceName: 'HIVE',
  336. serviceConfigValue: 'Existing MySQL Database',
  337. databaseName: 'db2',
  338. hostName: 'h2',
  339. databaseNameDefault: 'db2d',
  340. hostNameDefault: 'h2d',
  341. connectionUrlValue: 'jdbc:mysql://h2/db2?createDatabaseIfNotExist=true',
  342. connectionUrlDefaultValue: 'jdbc:mysql://h2d/db2d?createDatabaseIfNotExist=true',
  343. dbClassValue: 'com.mysql.jdbc.Driver',
  344. isAuthVisibleAndRequired: true,
  345. hiveDbTypeValue: 'mysql'
  346. },
  347. {
  348. serviceName: 'HIVE',
  349. serviceConfigValue: 'Existing MSSQL Server database with SQL authentication',
  350. databaseName: 'db3',
  351. hostName: 'h3',
  352. databaseNameDefault: 'db3d',
  353. hostNameDefault: 'h3d',
  354. connectionUrlValue: 'jdbc:sqlserver://h3;databaseName=db3',
  355. connectionUrlDefaultValue: 'jdbc:sqlserver://h3d;databaseName=db3d',
  356. dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
  357. isAuthVisibleAndRequired: true,
  358. hiveDbTypeValue: 'mssql'
  359. },
  360. {
  361. serviceName: 'HIVE',
  362. serviceConfigValue: 'Existing Oracle Database',
  363. databaseName: 'db4',
  364. hostName: 'h4',
  365. databaseNameDefault: 'db4d',
  366. hostNameDefault: 'h4d',
  367. connectionUrlValue: 'jdbc:oracle:thin:@//h4:1521/db4',
  368. connectionUrlDefaultValue: 'jdbc:oracle:thin:@//h4d:1521/db4d',
  369. dbClassValue: 'oracle.jdbc.driver.OracleDriver',
  370. isAuthVisibleAndRequired: true,
  371. hiveDbTypeValue: 'oracle'
  372. },
  373. {
  374. serviceName: 'HIVE',
  375. serviceConfigValue: 'Existing MSSQL Server database with integrated authentication',
  376. databaseName: 'db5',
  377. hostName: 'h5',
  378. databaseNameDefault: 'db5d',
  379. hostNameDefault: 'h5d',
  380. connectionUrlValue: 'jdbc:sqlserver://h5;databaseName=db5;integratedSecurity=true',
  381. connectionUrlDefaultValue: 'jdbc:sqlserver://h5d;databaseName=db5d;integratedSecurity=true',
  382. dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
  383. isAuthVisibleAndRequired: false,
  384. hiveDbTypeValue: 'mssql'
  385. },
  386. {
  387. serviceName: 'OOZIE',
  388. serviceConfigValue: 'New Derby Database',
  389. databaseName: 'db6',
  390. hostName: 'h6',
  391. databaseNameDefault: 'db6d',
  392. hostNameDefault: 'h6d',
  393. connectionUrlValue: 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true',
  394. connectionUrlDefaultValue: 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true',
  395. dbClassValue: 'org.apache.derby.jdbc.EmbeddedDriver',
  396. isAuthVisibleAndRequired: true
  397. },
  398. {
  399. serviceName: 'OOZIE',
  400. serviceConfigValue: 'Existing MySQL Database',
  401. databaseName: 'db7',
  402. hostName: 'h7',
  403. databaseNameDefault: 'db7d',
  404. hostNameDefault: 'h7d',
  405. connectionUrlValue: 'jdbc:mysql://h7/db7',
  406. connectionUrlDefaultValue: 'jdbc:mysql://h7/db7',
  407. dbClassValue: 'com.mysql.jdbc.Driver',
  408. isAuthVisibleAndRequired: true
  409. },
  410. {
  411. serviceName: 'OOZIE',
  412. serviceConfigValue: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
  413. databaseName: 'db8',
  414. hostName: 'h8',
  415. databaseNameDefault: 'db8d',
  416. hostNameDefault: 'h8d',
  417. connectionUrlValue: 'jdbc:postgresql://h8:5432/db8',
  418. connectionUrlDefaultValue: 'jdbc:postgresql://h8:5432/db8',
  419. dbClassValue: 'org.postgresql.Driver',
  420. isAuthVisibleAndRequired: true
  421. },
  422. {
  423. serviceName: 'OOZIE',
  424. serviceConfigValue: 'Existing MSSQL Server database with SQL authentication',
  425. databaseName: 'db9',
  426. hostName: 'h9',
  427. databaseNameDefault: 'db9d',
  428. hostNameDefault: 'h9d',
  429. connectionUrlValue: 'jdbc:sqlserver://h9;databaseName=db9',
  430. connectionUrlDefaultValue: 'jdbc:sqlserver://h9;databaseName=db9',
  431. dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
  432. isAuthVisibleAndRequired: true
  433. },
  434. {
  435. serviceName: 'OOZIE',
  436. serviceConfigValue: 'Existing Oracle Database',
  437. databaseName: 'db10',
  438. hostName: 'h10',
  439. databaseNameDefault: 'db10d',
  440. hostNameDefault: 'h10d',
  441. connectionUrlValue: 'jdbc:oracle:thin:@//h10:1521/db10',
  442. connectionUrlDefaultValue: 'jdbc:oracle:thin:@//h10:1521/db10',
  443. dbClassValue: 'oracle.jdbc.driver.OracleDriver',
  444. isAuthVisibleAndRequired: true
  445. },
  446. {
  447. serviceName: 'OOZIE',
  448. serviceConfigValue: 'Existing MSSQL Server database with integrated authentication',
  449. databaseName: 'db11',
  450. hostName: 'h11',
  451. databaseNameDefault: 'db11d',
  452. hostNameDefault: 'h11d',
  453. connectionUrlValue: 'jdbc:sqlserver://h11;databaseName=db11;integratedSecurity=true',
  454. connectionUrlDefaultValue: 'jdbc:sqlserver://h11;databaseName=db11;integratedSecurity=true',
  455. dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
  456. isAuthVisibleAndRequired: false
  457. }
  458. ],
  459. serviceAuthPropsMap = {
  460. HIVE: ['javax.jdo.option.ConnectionUserName', 'javax.jdo.option.ConnectionPassword'],
  461. OOZIE: ['oozie.service.JPAService.jdbc.username', 'oozie.service.JPAService.jdbc.password']
  462. };
  463. beforeEach(function () {
  464. sinon.stub(view, 'handleDBConnectionProperty', Em.K);
  465. sinon.stub(App.Service, 'find').returns([
  466. {
  467. serviceName: 'HIVE'
  468. }
  469. ]);
  470. });
  471. afterEach(function () {
  472. view.handleDBConnectionProperty.restore();
  473. App.Service.find.restore();
  474. });
  475. cases.forEach(function (item) {
  476. it(item.serviceName + ', ' + item.serviceConfigValue, function () {
  477. view.get('serviceConfig').setProperties({
  478. serviceName: item.serviceName,
  479. value: item.serviceConfigValue
  480. });
  481. view.setProperties({
  482. databaseName: item.databaseName,
  483. hostName: item.hostName,
  484. databaseNameProperty: Em.Object.create({
  485. defaultValue: item.databaseNameDefault
  486. }),
  487. hostNameProperty: Em.Object.create({
  488. defaultValue: item.hostNameDefault
  489. })
  490. });
  491. expect(view.get('connectionUrl.value')).to.equal(item.connectionUrlValue);
  492. expect(view.get('connectionUrl.defaultValue')).to.equal(item.connectionUrlDefaultValue);
  493. expect(view.get('dbClass.value')).to.equal(item.dbClassValue);
  494. serviceAuthPropsMap[item.serviceName].forEach(function (propName) {
  495. expect(view.get('categoryConfigsAll').findProperty('name', propName).get('isVisible')).to.equal(item.isAuthVisibleAndRequired);
  496. expect(view.get('categoryConfigsAll').findProperty('name', propName).get('isRequired')).to.equal(item.isAuthVisibleAndRequired);
  497. });
  498. if (item.serviceName == 'HIVE') {
  499. expect(view.get('parentView.serviceConfigs').findProperty('name', 'hive_database_type').value).to.equal(item.hiveDbTypeValue);
  500. }
  501. });
  502. });
  503. });
  504. });
  505. describe('App.ServiceConfigRadioButton', function () {
  506. describe('#disabled', function () {
  507. var cases = [
  508. {
  509. wizardControllerName: 'addServiceController',
  510. value: 'New MySQL Database',
  511. title: 'Add Service Wizard, new database',
  512. disabled: false
  513. },
  514. {
  515. wizardControllerName: 'installerController',
  516. value: 'New MySQL Database',
  517. title: 'Install Wizard, new database',
  518. disabled: false
  519. },
  520. {
  521. wizardControllerName: 'addServiceController',
  522. value: 'Existing MySQL Database',
  523. title: 'Add Service Wizard, existing database',
  524. disabled: false
  525. },
  526. {
  527. wizardControllerName: 'installerController',
  528. value: 'Existing MySQL Database',
  529. title: 'Install Wizard, existing database',
  530. disabled: false
  531. },
  532. {
  533. wizardControllerName: null,
  534. value: 'New MySQL Database',
  535. title: 'No installer, new database',
  536. disabled: true
  537. },
  538. {
  539. wizardControllerName: null,
  540. value: 'Existing MySQL Database',
  541. title: 'No installer, existing database',
  542. disabled: false
  543. }
  544. ];
  545. cases.forEach(function (item) {
  546. it(item.title, function () {
  547. var view = App.ServiceConfigRadioButton.create({
  548. parentView: Em.Object.create({
  549. serviceConfig: Em.Object.create()
  550. }),
  551. controller: Em.Object.create({
  552. wizardController: Em.Object.create({
  553. name: null
  554. })
  555. })
  556. });
  557. view.set('value', item.value);
  558. view.set('controller.wizardController.name', item.wizardControllerName);
  559. view.set('parentView.serviceConfig.isEditable', true);
  560. expect(view.get('disabled')).to.equal(item.disabled);
  561. });
  562. });
  563. it('parent view is disabled', function () {
  564. var view = App.ServiceConfigRadioButton.create({
  565. parentView: Em.Object.create({
  566. serviceConfig: Em.Object.create()
  567. })
  568. });
  569. view.set('parentView.serviceConfig.isEditable', false);
  570. expect(view.get('disabled')).to.be.true;
  571. });
  572. });
  573. });
  574. describe('App.CheckDBConnectionView', function () {
  575. describe('#masterHostName', function () {
  576. var cases = [
  577. {
  578. serviceName: 'OOZIE',
  579. value: 'h0'
  580. },
  581. {
  582. serviceName: 'KERBEROS',
  583. value: 'h1'
  584. },
  585. {
  586. serviceName: 'HIVE',
  587. value: 'h2'
  588. }
  589. ],
  590. categoryConfigsAll = [
  591. Em.Object.create({
  592. name: 'oozie_ambari_host',
  593. value: 'h0'
  594. }),
  595. Em.Object.create({
  596. name: 'kdc_host',
  597. value: 'h1'
  598. }),
  599. Em.Object.create({
  600. name: 'hive_ambari_host',
  601. value: 'h2'
  602. })
  603. ];
  604. cases.forEach(function (item) {
  605. it(item.serviceName, function () {
  606. var view = App.CheckDBConnectionView.create({
  607. parentView: {
  608. service: {
  609. serviceName: item.serviceName
  610. },
  611. categoryConfigsAll: categoryConfigsAll
  612. }
  613. });
  614. expect(view.get('masterHostName')).to.equal(item.value);
  615. });
  616. });
  617. });
  618. });
  619. describe('App.BaseUrlTextField', function () {
  620. var view;
  621. beforeEach(function () {
  622. view = App.BaseUrlTextField.create({
  623. repository: Em.Object.create({
  624. baseUrl: 'val'
  625. })
  626. });
  627. view.didInsertElement();
  628. });
  629. describe('#valueWasChanged', function () {
  630. it('should be recalculated after value is changed', function () {
  631. view.setProperties({
  632. value: 'val',
  633. defaultValue: 'val'
  634. });
  635. expect(view.get('valueWasChanged')).to.be.false;
  636. view.set('value', 'newVal');
  637. expect(view.get('valueWasChanged')).to.be.true;
  638. });
  639. });
  640. describe('#restoreValue', function () {
  641. it('should unset value', function () {
  642. view.setProperties({
  643. value: 'valNew',
  644. defaultValue: 'val'
  645. });
  646. view.restoreValue();
  647. expect(view.get('value')).to.equal('val');
  648. });
  649. });
  650. });