Passed
Push — master ( 7fa532...129142 )
by Ahmed
02:32
created

__test__/helpers.test.js   A

Complexity

Total Complexity 8
Complexity/F 1

Size

Lines of Code 48
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 8
mnd 0
bc 0
fnc 8
bpm 0
cpm 1
noi 4
1
import {
2
  hillFn,
3
  hillFnInverse,
4
  textOutRange,
5
  calculateTextPositionForX,
6
} from '../src/helpers';
7
8
describe('hill chart function', () => {
9
  it('computes correct values', () => {
10
    expect.hasAssertions();
11
    expect(hillFn(0)).toEqual(0);
12
    expect(hillFn(25)).toEqual(50.000000000000014);
13
    expect(hillFn(50)).toEqual(100);
14
    expect(hillFn(100)).toEqual(0);
15
  });
16
});
17
18
describe('hill chart inverse function', () => {
19
  it('computes correct values', () => {
20
    expect.hasAssertions();
21
    expect(hillFnInverse(0)).toEqual(0);
22
    expect(hillFnInverse(25)).toEqual(16.666666666666664);
23
    expect(hillFnInverse(50)).toEqual(25);
24
    expect(hillFnInverse(100)).toEqual(50);
25
  });
26
});
27
28
describe('out of range function', () => {
29
  it('returns true when passed value between 80 and 100', () => {
30
    expect.hasAssertions();
31
    expect(textOutRange(20)).toBe(false);
32
    expect(textOutRange(80)).toBe(true);
33
    expect(textOutRange(100)).toBe(true);
34
  });
35
});
36
37
describe('calculate text position on x axis', () => {
38
  it('returns positive value if text isnt out of range and negative it is. based on the point size and x axis position', () => {
39
    expect.hasAssertions();
40
    let pointSize = 10;
41
    let x = 50;
42
    expect(calculateTextPositionForX(pointSize, x)).toEqual(15);
43
44
    pointSize = 15;
45
    x = 80;
46
    expect(calculateTextPositionForX(pointSize, x)).toBe(-20);
47
  });
48
});
49