blob: 03533985c3541a65983e61170e564b0acb2024ef [file] [log] [blame]
Matteo Scandolocc0db942016-02-11 17:37:08 -08001(function () {
2 'use strict';
3
4 describe('The Logic Topology Helper Service', () => {
5
6 var Service;
7
8 beforeEach(module('xos.serviceTopology'));
9
10 // inject the rackHelper service
11 beforeEach(inject(function (_LogicTopologyHelper_) {
12 // The injector unwraps the underscores (_) from around the parameter names when matching
13 Service = _LogicTopologyHelper_;
14 }));
15
16 var customMatchers = {
17 toBeSimilar: () => {
18
19 const tolerance = 0.1;
20
21 return {
22 compare: (actual, expected) => {
23 return {
24 pass: (Math.abs(actual - expected) < tolerance),
25 message: `Expected ${actual} to be ${expected}`
26 }
27 }
28 }
29 }
30 };
31
32 beforeEach(function() {
33 jasmine.addMatchers(customMatchers);
34 });
35
36 it('should calculate horizontal position for each element', () => {
37 let [el0x, el1x, el2x, el3x, el4x, el5x] = Service.computeElementPosition(900);
38
39 expect(el0x).toBeSimilar(900 - 30);
40 expect(el1x).toBeSimilar(900 - 183.4);
41 expect(el2x).toBeSimilar(900 - 337.3);
42 expect(el3x).toBeSimilar(900 - 490.7);
43 expect(el4x).toBeSimilar(900 - 602.1);
44 expect(el5x).toBeSimilar(900 - 713.5);
45 });
46 });
47
48})();