Skip to content

Commit 50e2641

Browse files
committed
add simple test case
1 parent cff2ca1 commit 50e2641

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

src/__tests__/simple.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
'use strict';
2+
3+
var gsd = require('../gsd');
4+
5+
describe('Simple test cases', () => {
6+
let X = [];
7+
let Y = [];
8+
for (let i = 0; i < 10; i++) {
9+
X.push(X.length);
10+
Y.push(0);
11+
}
12+
for (let i = 0; i <= 10; i++) {
13+
X.push(X.length);
14+
Y.push(i > 5 ? 10 - i : i);
15+
}
16+
for (let i = 0; i < 10; i++) {
17+
X.push(X.length);
18+
Y.push(0);
19+
}
20+
21+
it('gsd not realtop', () => {
22+
let peaks = gsd(X, Y, {
23+
realTopDetection: false,
24+
smoothY: true,
25+
sgOptions: {
26+
windowSize: 5,
27+
polynomial: 3
28+
}
29+
});
30+
31+
expect(peaks).toStrictEqual([
32+
{
33+
base: 1.1956287811760204,
34+
index: 15,
35+
soft: false,
36+
width: 2,
37+
x: 15,
38+
y: 4.657142857142857
39+
}
40+
]);
41+
});
42+
43+
it('gsd not realtop asymetric', () => {
44+
let Y2 = Y.slice(0);
45+
Y2[14] = 5;
46+
let peaks = gsd(X, Y2, {
47+
realTopDetection: false,
48+
smoothY: true,
49+
sgOptions: {
50+
windowSize: 5,
51+
polynomial: 3
52+
}
53+
});
54+
55+
expect(peaks).toStrictEqual([
56+
{
57+
base: 1.2434539324230613,
58+
index: 15,
59+
soft: false,
60+
width: 3,
61+
x: 15,
62+
y: 5
63+
}
64+
]);
65+
});
66+
67+
it('gsd realtop', () => {
68+
let Y2 = Y.slice();
69+
Y2[14] = 5;
70+
let peaks = gsd(X, Y2, {
71+
realTopDetection: true,
72+
smoothY: true,
73+
sgOptions: {
74+
windowSize: 5,
75+
polynomial: 3
76+
}
77+
});
78+
79+
expect(peaks).toStrictEqual([
80+
{
81+
base: 1.2434539324230613,
82+
index: 15,
83+
soft: false,
84+
width: 3,
85+
x: 14.755485084898725,
86+
y: 3.7914767697342637
87+
}
88+
]);
89+
});
90+
});

0 commit comments

Comments
 (0)