Skip to content

Commit

Permalink
test(libs): Throw errors when weightOption is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
freshsomebody committed Jul 5, 2020
1 parent 6b34884 commit d74ac95
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/libs/vectorizeAndNormalize.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import * as funcs from '../../src/libs/vectorizeAndNormalize';
import mockPoseData from '../mock-pose-data.json';
import { WeightOption, WeightOptionMode } from '../../src/types';

describe('vectorizeAndNormalize.ts', () => {
test('convertPoseToVectors throws errors if weightOption is invalid', () => {
const badCustomWeightErrMsg = new RegExp(/Bad customWeight option/);

expect(() => funcs.convertPoseToVectors(mockPoseData[0], {} as WeightOption)).toThrow(badCustomWeightErrMsg);

expect(() => {
funcs.convertPoseToVectors(mockPoseData[0], { mode: 'wrong' as WeightOptionMode } as WeightOption)
}).toThrow(badCustomWeightErrMsg);

expect(() => {
funcs.convertPoseToVectors(mockPoseData[0], { mode: 'multiply' } as WeightOption)
}).toThrow(badCustomWeightErrMsg);
})

test('convertPoseToVectors returns correct results', () => {
// without weightOption
expect(funcs.convertPoseToVectors(mockPoseData[0])).toEqual([
Expand Down

0 comments on commit d74ac95

Please sign in to comment.