step2_controller_test.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. App = require('app');
  19. require('controllers/main/service/widgets/create/step2_controller');
  20. describe('App.WidgetWizardStep2Controller', function () {
  21. var controller = App.WidgetWizardStep2Controller.create({
  22. content: Em.Object.create()
  23. });
  24. App.TestAliases.testAsComputedEqual(controller, 'isEditWidget', 'content.controllerName', 'widgetEditController');
  25. describe("#filteredMetrics", function () {
  26. var testCases = [
  27. {
  28. metric: {
  29. point_in_time: false
  30. },
  31. type: null,
  32. result: []
  33. },
  34. {
  35. metric: {
  36. point_in_time: true
  37. },
  38. type: null,
  39. result: [
  40. {
  41. point_in_time: true
  42. }
  43. ]
  44. },
  45. {
  46. metric: {
  47. temporal: false
  48. },
  49. type: 'GRAPH',
  50. result: []
  51. },
  52. {
  53. metric: {
  54. temporal: true
  55. },
  56. type: 'GRAPH',
  57. result: [
  58. {
  59. temporal: true
  60. }
  61. ]
  62. }
  63. ];
  64. testCases.forEach(function (test) {
  65. it("type=" + test.type + "; temporal=" + test.metric.temporal + "; point_in_time=" + test.metric.point_in_time, function () {
  66. controller.get('content').setProperties({
  67. widgetType: test.type,
  68. allMetrics: [test.metric]
  69. });
  70. controller.propertyDidChange('filteredMetrics');
  71. expect(controller.get('filteredMetrics')).to.eql(test.result);
  72. });
  73. });
  74. });
  75. describe("#isSubmitDisabled", function () {
  76. beforeEach(function () {
  77. this.expressionFunc = sinon.stub(controller, 'isExpressionComplete');
  78. this.graphFunc = sinon.stub(controller, 'isGraphDataComplete');
  79. this.templateFunc = sinon.stub(controller, 'isTemplateDataComplete');
  80. controller.set('expressions', ['']);
  81. });
  82. afterEach(function () {
  83. this.expressionFunc.restore();
  84. this.graphFunc.restore();
  85. this.templateFunc.restore();
  86. controller.get('expressions').clear();
  87. });
  88. it("invalid property", function () {
  89. controller.set('widgetPropertiesViews', [Em.Object.create({isValid: false})]);
  90. controller.propertyDidChange('isSubmitDisabled');
  91. expect(controller.get('isSubmitDisabled')).to.be.true;
  92. });
  93. it("valid number widget", function () {
  94. controller.set('widgetPropertiesViews', []);
  95. controller.set('content.widgetType', 'NUMBER');
  96. this.expressionFunc.returns(true);
  97. controller.propertyDidChange('isSubmitDisabled');
  98. expect(controller.get('isSubmitDisabled')).to.be.false;
  99. });
  100. it("invalid number widget", function () {
  101. controller.set('widgetPropertiesViews', []);
  102. controller.set('content.widgetType', 'NUMBER');
  103. this.expressionFunc.returns(false);
  104. controller.propertyDidChange('isSubmitDisabled');
  105. expect(controller.get('isSubmitDisabled')).to.be.true;
  106. });
  107. it("valid graph widget", function () {
  108. controller.set('widgetPropertiesViews', []);
  109. controller.set('content.widgetType', 'GRAPH');
  110. this.graphFunc.returns(true);
  111. controller.propertyDidChange('isSubmitDisabled');
  112. expect(controller.get('isSubmitDisabled')).to.be.false;
  113. });
  114. it("invalid graph widget", function () {
  115. controller.set('widgetPropertiesViews', []);
  116. controller.set('content.widgetType', 'GRAPH');
  117. this.graphFunc.returns(false);
  118. controller.propertyDidChange('isSubmitDisabled');
  119. expect(controller.get('isSubmitDisabled')).to.be.true;
  120. });
  121. it("valid template widget", function () {
  122. controller.set('widgetPropertiesViews', []);
  123. controller.set('content.widgetType', 'TEMPLATE');
  124. this.templateFunc.returns(true);
  125. controller.propertyDidChange('isSubmitDisabled');
  126. expect(controller.get('isSubmitDisabled')).to.be.false;
  127. });
  128. it("invalid template widget", function () {
  129. controller.set('widgetPropertiesViews', []);
  130. controller.set('content.widgetType', 'TEMPLATE');
  131. this.templateFunc.returns(false);
  132. controller.propertyDidChange('isSubmitDisabled');
  133. expect(controller.get('isSubmitDisabled')).to.be.true;
  134. });
  135. it("unknown widget type", function () {
  136. controller.set('widgetPropertiesViews', []);
  137. controller.set('content.widgetType', '');
  138. controller.propertyDidChange('isSubmitDisabled');
  139. expect(controller.get('isSubmitDisabled')).to.be.false;
  140. });
  141. });
  142. describe("#isExpressionComplete()", function () {
  143. var testCases = [
  144. {
  145. expression: null,
  146. result: false
  147. },
  148. {
  149. expression: Em.Object.create({isInvalid: true}),
  150. result: false
  151. },
  152. {
  153. expression: Em.Object.create({isInvalid: false, isEmpty: false}),
  154. result: true
  155. },
  156. {
  157. expression: Em.Object.create({isInvalid: false, isEmpty: true}),
  158. result: false
  159. }
  160. ];
  161. testCases.forEach(function (test) {
  162. it("expression = " + test.expression, function () {
  163. expect(controller.isExpressionComplete(test.expression)).to.equal(test.result);
  164. });
  165. });
  166. });
  167. describe("#isGraphDataComplete()", function () {
  168. beforeEach(function () {
  169. this.mock = sinon.stub(controller, 'isExpressionComplete');
  170. });
  171. afterEach(function () {
  172. this.mock.restore();
  173. });
  174. it("dataSets is empty", function () {
  175. expect(controller.isGraphDataComplete([])).to.be.false;
  176. });
  177. it("label is empty", function () {
  178. expect(controller.isGraphDataComplete([Em.Object.create({label: ''})])).to.be.false;
  179. });
  180. it("expression is not complete", function () {
  181. this.mock.returns(false);
  182. expect(controller.isGraphDataComplete([Em.Object.create({label: 'abc'})])).to.be.false;
  183. });
  184. it("expression is complete", function () {
  185. this.mock.returns(true);
  186. expect(controller.isGraphDataComplete([Em.Object.create({label: 'abc'})])).to.be.true;
  187. });
  188. });
  189. describe("#isTemplateDataComplete()", function () {
  190. beforeEach(function () {
  191. this.mock = sinon.stub(controller, 'isExpressionComplete');
  192. });
  193. afterEach(function () {
  194. this.mock.restore();
  195. });
  196. it("expressions is empty", function () {
  197. expect(controller.isTemplateDataComplete([])).to.be.false;
  198. });
  199. it("templateValue is empty", function () {
  200. expect(controller.isTemplateDataComplete([{}], '')).to.be.false;
  201. });
  202. it("expression is not complete", function () {
  203. this.mock.returns(false);
  204. expect(controller.isTemplateDataComplete([{}], 'abc')).to.be.false;
  205. });
  206. it("expression is complete", function () {
  207. this.mock.returns(true);
  208. expect(controller.isTemplateDataComplete([{}], 'abc')).to.be.true;
  209. });
  210. });
  211. describe("#addDataSet()", function () {
  212. beforeEach(function () {
  213. controller.get('dataSets').clear();
  214. controller.addDataSet(null, true);
  215. controller.addDataSet(null);
  216. });
  217. afterEach(function() {
  218. controller.get('dataSets').clear();
  219. });
  220. it('check id', function () {
  221. expect(controller.get('dataSets').mapProperty('id')).to.eql([1, 2]);
  222. });
  223. it('check isRemovable', function () {
  224. expect(controller.get('dataSets').mapProperty('isRemovable')).to.eql([false, true]);
  225. });
  226. });
  227. describe("#removeDataSet()", function () {
  228. it('should remove selected dataSet', function () {
  229. var dataSet = Em.Object.create();
  230. controller.get('dataSets').pushObject(dataSet);
  231. controller.removeDataSet({context: dataSet});
  232. expect(controller.get('dataSets')).to.be.empty;
  233. });
  234. });
  235. describe("#addExpression()", function () {
  236. beforeEach(function () {
  237. controller.get('expressions').clear();
  238. controller.addExpression(null, true);
  239. controller.addExpression(null);
  240. });
  241. afterEach(function () {
  242. controller.get('expressions').clear();
  243. });
  244. it('check id', function () {
  245. expect(controller.get('expressions').mapProperty('id')).to.eql([1, 2]);
  246. });
  247. it('check isRemovable', function () {
  248. expect(controller.get('expressions').mapProperty('isRemovable')).to.eql([false, true]);
  249. });
  250. });
  251. describe("#removeExpression()", function () {
  252. it("should remove selected expression", function () {
  253. var expression = Em.Object.create();
  254. controller.get('expressions').pushObject(expression);
  255. controller.removeExpression({context: expression});
  256. expect(controller.get('expressions')).to.be.empty;
  257. });
  258. });
  259. describe("#initWidgetData()", function () {
  260. describe("new data", function () {
  261. beforeEach(function () {
  262. controller.set('expressions', []);
  263. controller.set('dataSets', []);
  264. controller.get('content').setProperties({
  265. widgetProperties: {a: 1},
  266. widgetValues: [1],
  267. widgetMetrics: [2]
  268. });
  269. controller.initWidgetData();
  270. });
  271. it('widgetProperties is {a: 1}', function () {
  272. expect(controller.get('widgetProperties')).to.eql({a: 1});
  273. });
  274. it('widgetValues is []', function () {
  275. expect(controller.get('widgetValues')).to.eql([]);
  276. });
  277. it('widgetMetrics is []', function () {
  278. expect(controller.get('widgetMetrics')).to.eql([]);
  279. });
  280. it('expressions is not empty', function () {
  281. expect(controller.get('expressions')).to.not.be.empty;
  282. });
  283. it('dataSets is not empty', function () {
  284. expect(controller.get('dataSets')).to.not.be.empty;
  285. });
  286. });
  287. describe("previously edited", function () {
  288. beforeEach(function () {
  289. controller.set('expressions', [{}]);
  290. controller.set('dataSets', [{}]);
  291. controller.get('content').setProperties({
  292. widgetProperties: {a: 1},
  293. widgetValues: [1],
  294. widgetMetrics: [2]
  295. });
  296. controller.initWidgetData();
  297. });
  298. it('widgetProperties is {a: 1}', function () {
  299. expect(controller.get('widgetProperties')).to.eql({a: 1});
  300. });
  301. it('widgetValues is [1]', function () {
  302. expect(controller.get('widgetValues')).to.eql([1]);
  303. });
  304. it('widgetMetrics is [2]', function () {
  305. expect(controller.get('widgetMetrics')).to.eql([2]);
  306. });
  307. it('expressions is not empty', function () {
  308. expect(controller.get('expressions')).to.not.be.empty;
  309. });
  310. it('dataSets is not empty', function () {
  311. expect(controller.get('dataSets')).to.not.be.empty;
  312. });
  313. });
  314. });
  315. describe("#updateExpressions()", function () {
  316. beforeEach(function () {
  317. sinon.stub(controller, 'parseExpression').returns({values: [1], metrics: [1]});
  318. sinon.stub(controller, 'parseTemplateExpression').returns({values: [1], metrics: [1]});
  319. sinon.stub(controller, 'parseGraphDataset').returns({values: [1], metrics: [1]});
  320. });
  321. afterEach(function () {
  322. controller.parseExpression.restore();
  323. controller.parseTemplateExpression.restore();
  324. controller.parseGraphDataset.restore();
  325. });
  326. describe("empty expressions", function () {
  327. beforeEach(function () {
  328. controller.set('expressions', []);
  329. controller.updateExpressions();
  330. });
  331. it('parseExpression is not called', function () {
  332. expect(controller.parseExpression.called).to.be.false;
  333. });
  334. it('parseTemplateExpression is not called', function () {
  335. expect(controller.parseTemplateExpression.called).to.be.false;
  336. });
  337. it('parseGraphDataset is not called', function () {
  338. expect(controller.parseGraphDataset.called).to.be.false;
  339. });
  340. it('widgetValues is empty', function () {
  341. expect(controller.get('widgetValues')).to.be.empty;
  342. });
  343. it('widgetMetrics is empty', function () {
  344. expect(controller.get('widgetMetrics')).to.be.empty;
  345. });
  346. });
  347. describe("empty dataSets", function () {
  348. beforeEach(function () {
  349. controller.set('dataSets', []);
  350. controller.updateExpressions();
  351. });
  352. it('parseExpression is not called', function () {
  353. expect(controller.parseExpression.called).to.be.false;
  354. });
  355. it('parseTemplateExpression is not called', function () {
  356. expect(controller.parseTemplateExpression.called).to.be.false;
  357. });
  358. it('parseGraphDataset is not called', function () {
  359. expect(controller.parseGraphDataset.called).to.be.false;
  360. });
  361. it('widgetValues is empty', function () {
  362. expect(controller.get('widgetValues')).to.be.empty;
  363. });
  364. it('widgetMetrics is empty', function () {
  365. expect(controller.get('widgetMetrics')).to.be.empty;
  366. });
  367. });
  368. describe("GAUGE widget", function () {
  369. beforeEach(function () {
  370. controller.set('expressions', [{}]);
  371. controller.set('content.widgetType', 'GAUGE');
  372. controller.set('dataSets', [{}]);
  373. //controller.updateExpressions();
  374. });
  375. it('parseExpression is called once', function () {
  376. expect(controller.parseExpression.calledOnce).to.be.true;
  377. });
  378. it('parseTemplateExpression is not called', function () {
  379. expect(controller.parseTemplateExpression.called).to.be.false;
  380. });
  381. it('parseGraphDataset is not called', function () {
  382. expect(controller.parseGraphDataset.called).to.be.false;
  383. });
  384. it('widgetValues is not empty', function () {
  385. expect(controller.get('widgetValues')).to.not.be.empty;
  386. });
  387. it('widgetMetrics is not empty', function () {
  388. expect(controller.get('widgetMetrics')).to.not.be.empty;
  389. });
  390. });
  391. describe("NUMBER widget", function () {
  392. beforeEach(function () {
  393. controller.set('expressions', [{}]);
  394. controller.set('content.widgetType', 'NUMBER');
  395. controller.set('dataSets', [{}]);
  396. //controller.updateExpressions();
  397. });
  398. it('parseExpression is called once', function () {
  399. expect(controller.parseExpression.calledOnce).to.be.true;
  400. });
  401. it('parseTemplateExpression is not called', function () {
  402. expect(controller.parseTemplateExpression.called).to.be.false;
  403. });
  404. it('parseGraphDataset is not called', function () {
  405. expect(controller.parseGraphDataset.called).to.be.false;
  406. });
  407. it('widgetValues is not empty', function () {
  408. expect(controller.get('widgetValues')).to.not.be.empty;
  409. });
  410. it('widgetMetrics is not empty', function () {
  411. expect(controller.get('widgetMetrics')).to.not.be.empty;
  412. });
  413. });
  414. describe("TEMPLATE widget", function () {
  415. beforeEach(function () {
  416. controller.set('expressions', [{}]);
  417. controller.set('content.widgetType', 'TEMPLATE');
  418. controller.set('dataSets', [{}]);
  419. //controller.updateExpressions();
  420. });
  421. it('parseExpression is not called', function () {
  422. expect(controller.parseExpression.called).to.be.false;
  423. });
  424. it('parseTemplateExpression is called once', function () {
  425. expect(controller.parseTemplateExpression.calledOnce).to.be.true;
  426. });
  427. it('parseGraphDataset is not called', function () {
  428. expect(controller.parseGraphDataset.called).to.be.false;
  429. });
  430. it('widgetValues is not empty', function () {
  431. expect(controller.get('widgetValues')).to.not.be.empty;
  432. });
  433. it('widgetMetrics is not empty', function () {
  434. expect(controller.get('widgetMetrics')).to.not.be.empty;
  435. });
  436. });
  437. describe("GRAPH widget", function () {
  438. beforeEach(function () {
  439. controller.set('expressions', [{}]);
  440. controller.set('content.widgetType', 'GRAPH');
  441. controller.set('dataSets', [{}]);
  442. //controller.updateExpressions();
  443. });
  444. it('parseExpression is not called', function () {
  445. expect(controller.parseExpression.called).to.be.false;
  446. });
  447. it('parseTemplateExpression is not called', function () {
  448. expect(controller.parseTemplateExpression.called).to.be.false;
  449. });
  450. it('parseGraphDataset is called once', function () {
  451. expect(controller.parseGraphDataset.calledOnce).to.be.true;
  452. });
  453. it('widgetValues is not empty', function () {
  454. expect(controller.get('widgetValues')).to.not.be.empty;
  455. });
  456. it('widgetMetrics is not empty', function () {
  457. expect(controller.get('widgetMetrics')).to.not.be.empty;
  458. });
  459. });
  460. });
  461. describe("#parseGraphDataset()", function () {
  462. beforeEach(function () {
  463. sinon.stub(controller, 'parseExpression').returns({value: 'value'});
  464. });
  465. afterEach(function () {
  466. controller.parseExpression.restore();
  467. });
  468. it("empty dataSets", function () {
  469. expect(controller.parseGraphDataset([])).to.be.eql({
  470. metrics: [],
  471. values: []
  472. });
  473. });
  474. it("correct dataSets", function () {
  475. var result = controller.parseGraphDataset([Em.Object.create({label: 'label'})]);
  476. expect(result.values).to.be.eql([
  477. {
  478. "name": "label",
  479. "value": "value"
  480. }
  481. ]);
  482. expect(result.metrics).to.be.empty;
  483. });
  484. });
  485. describe("#parseTemplateExpression()", function () {
  486. beforeEach(function () {
  487. sinon.stub(controller, 'parseExpression').returns({value: 'value'});
  488. });
  489. afterEach(function () {
  490. controller.parseExpression.restore();
  491. });
  492. it("empty expressions", function () {
  493. expect(controller.parseTemplateExpression("{{Expression1}}", [])).to.be.eql({
  494. metrics: [],
  495. values: [
  496. {
  497. value: "{{Expression1}}"
  498. }
  499. ]
  500. });
  501. });
  502. it("correct expressions", function () {
  503. var result = controller.parseTemplateExpression("{{Expression1}}", [Em.Object.create({alias: '{{Expression1}}'})]);
  504. expect(result.values).to.be.eql([
  505. {
  506. value: "value"
  507. }
  508. ]);
  509. expect(result.metrics).to.be.empty;
  510. });
  511. });
  512. describe("#parseExpression()", function () {
  513. it("expression is empty", function () {
  514. expect(controller.parseExpression({data: []})).to.eql({
  515. metrics: [],
  516. value: ''
  517. });
  518. });
  519. it("expression is correct", function () {
  520. var data = [
  521. {
  522. name: 'm1',
  523. serviceName: 'S1',
  524. componentName: 'C1',
  525. metricPath: 'mp',
  526. hostComponentCriteria: 'hcc',
  527. isMetric: true
  528. },
  529. {
  530. name: '+'
  531. },
  532. {
  533. name: '10'
  534. }
  535. ];
  536. expect(controller.parseExpression({data: data})).to.eql({
  537. metrics: [
  538. {
  539. "name": "m1",
  540. "service_name": "S1",
  541. "component_name": "C1",
  542. "metric_path": "mp",
  543. "host_component_criteria": "hcc"
  544. }
  545. ],
  546. value: '${m1+10}'
  547. });
  548. });
  549. });
  550. describe("#updateProperties()", function () {
  551. it("widgetPropertiesViews is empty", function () {
  552. controller.set('widgetPropertiesViews', []);
  553. expect(controller.get('widgetProperties')).to.be.empty;
  554. });
  555. it("widgetPropertiesViews is correct", function () {
  556. controller.set('widgetPropertiesViews', [
  557. Em.Object.create({
  558. valueMap: {
  559. "key1": 'alias1'
  560. },
  561. key1: 1
  562. })
  563. ]);
  564. expect(controller.get('widgetProperties')).to.eql({
  565. "alias1": 1
  566. });
  567. });
  568. });
  569. describe("#renderProperties()", function () {
  570. beforeEach(function () {
  571. this.mock = sinon.stub(App.WidgetType, 'find');
  572. sinon.stub(App.WidgetPropertyTypes, 'findProperty').returns({valueMap: {}});
  573. sinon.stub(App.WidgetProperty, 'create').returns({});
  574. });
  575. afterEach(function () {
  576. this.mock.restore();
  577. App.WidgetPropertyTypes.findProperty.restore();
  578. App.WidgetProperty.create.restore();
  579. });
  580. it("no properties", function () {
  581. this.mock.returns(Em.Object.create({properties: []}));
  582. controller.renderProperties();
  583. expect(controller.get('widgetPropertiesViews')).to.be.empty;
  584. });
  585. it("correct properties", function () {
  586. this.mock.returns(Em.Object.create({properties: [{}]}));
  587. controller.renderProperties();
  588. expect(App.WidgetProperty.create.calledWith({valueMap: {}})).to.be.true;
  589. expect(controller.get('widgetPropertiesViews')).to.not.be.empty;
  590. });
  591. });
  592. describe("#parseValue()", function () {
  593. beforeEach(function () {
  594. sinon.stub(controller, 'getExpressionData').returns({});
  595. });
  596. afterEach(function () {
  597. controller.getExpressionData.restore();
  598. });
  599. it("empty value", function () {
  600. expect(controller.parseValue("", [])).to.be.empty;
  601. });
  602. it("correct value", function () {
  603. expect(controller.parseValue("${m1}", [])).to.not.be.empty;
  604. expect(controller.getExpressionData.calledWith("m1", [])).to.be.true;
  605. });
  606. });
  607. describe("#getExpressionData()", function () {
  608. beforeEach(function () {
  609. sinon.stub(controller, 'getExpressionVariable').returns({});
  610. });
  611. afterEach(function () {
  612. controller.getExpressionVariable.restore();
  613. });
  614. it("empty expression", function () {
  615. expect(controller.getExpressionData("", [])).to.be.empty;
  616. });
  617. it("correct expression", function () {
  618. expect(controller.getExpressionData("m1+10", [])).to.not.be.empty;
  619. expect(controller.getExpressionVariable.getCall(0).args).to.eql(["m1", 1, []]);
  620. expect(controller.getExpressionVariable.getCall(1).args).to.eql(["10", 3, []]);
  621. });
  622. });
  623. describe("#getExpressionVariable()", function () {
  624. it("get metric definition", function () {
  625. var metrics = [
  626. {
  627. name: 'm1',
  628. component_name: 'C1',
  629. service_name: 'S1',
  630. metric_path: 'mp',
  631. host_component_criteria: 'hcc'
  632. }
  633. ];
  634. expect(controller.getExpressionVariable("m1", 1, metrics)).to.be.eql(Em.Object.create({
  635. id: 1,
  636. name: 'm1',
  637. isMetric: true,
  638. componentName: 'C1',
  639. serviceName: 'S1',
  640. metricPath: 'mp',
  641. hostComponentCriteria: 'hcc'
  642. }));
  643. });
  644. it("get number definition", function () {
  645. expect(controller.getExpressionVariable("10", 2, [])).to.be.eql(Em.Object.create({
  646. id: 2,
  647. name: "10",
  648. isNumber: true
  649. }));
  650. });
  651. });
  652. describe("#next()", function () {
  653. beforeEach(function () {
  654. sinon.stub(App.router, 'send');
  655. });
  656. afterEach(function () {
  657. App.router.send.restore();
  658. });
  659. it("user is moved to the next step", function () {
  660. controller.next();
  661. expect(App.router.send.calledWith('next')).to.be.true;
  662. });
  663. });
  664. });