Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(positiveflux): add tests for positive flux
also minor corrections in spectral flux and tests for that re #1074
- Loading branch information
1 parent
303cce9
commit 82b2731
Showing
4 changed files
with
51 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import TestData from "../TestData"; | ||
import { fft } from "fftjs"; | ||
|
||
// Setup | ||
var positiveFlux = require("../../dist/node/extractors/positiveFlux"); | ||
|
||
var COMPLEX_SPECTRUM = fft(TestData.VALID_SIGNAL); | ||
|
||
describe("positiveFlux", () => { | ||
test("should return correct Positive Flux value", (done) => { | ||
var en = positiveFlux({ | ||
complexSpectrum: COMPLEX_SPECTRUM, | ||
previousComplexSpectrum: { | ||
real: COMPLEX_SPECTRUM.real.map((e) => e * 0.8), | ||
}, | ||
bufferSize: TestData.VALID_SIGNAL.length, | ||
}); | ||
|
||
expect(en).toEqual(2.1288412531209104e-8); | ||
|
||
done(); | ||
}); | ||
|
||
test.skip("should throw an error when passed an empty object", (done) => { | ||
try { | ||
var en = positiveFlux({}); | ||
} catch (e) { | ||
done(); | ||
} | ||
}); | ||
|
||
test.skip("should throw an error when not passed anything", (done) => { | ||
try { | ||
var en = positiveFlux(); | ||
} catch (e) { | ||
done(); | ||
} | ||
}); | ||
|
||
test.skip("should throw an error when passed something invalid", (done) => { | ||
try { | ||
var en = positiveFlux({ signal: "not a signal" }); | ||
} catch (e) { | ||
done(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters