-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4a60e6
commit 8fe6b6f
Showing
1 changed file
with
43 additions
and
7 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 |
---|---|---|
@@ -1,12 +1,48 @@ | ||
import { expect, test } from '@jest/globals'; | ||
import defaultAwesomeFunction, { awesomeFunction } from '../src/index.js'; | ||
import smoothLandmarks from '../src/index.js'; | ||
|
||
test('Should test default awesome function', () => { | ||
const expectedVal = 'I am the Default Awesome Function, fellow comrade! - Yousuf'; | ||
expect(defaultAwesomeFunction('Yousuf')).toMatch(expectedVal); | ||
test('This will test the smooth landmarks function', () => { | ||
let expected = {}; | ||
|
||
// Simulating Mediapipe | ||
for (let i = 0; i < 8; i++) { | ||
const landmarks = { | ||
poseLandmarks: Array.from({ length: 33 }, () => ({ | ||
x: i + 1, | ||
y: i + 1, | ||
z: i + 1, | ||
visibility: 0, | ||
})), | ||
}; | ||
|
||
expected = smoothLandmarks(landmarks); | ||
} | ||
|
||
// We will test only the 1st entity | ||
expect(expected.poseLandmarks[0]?.x).toEqual(4.5); | ||
}); | ||
|
||
test('Should test awesome function', () => { | ||
const expectedVal = 'I am just an Awesome Function'; | ||
expect(awesomeFunction()).toMatch(expectedVal); | ||
test('This will test the smooth landmarks function by passing onResults', () => { | ||
let expected = {}; | ||
|
||
// Simulating Mediapipe | ||
for (let i = 0; i < 8; i++) { | ||
const landmarks = { | ||
poseLandmarks: Array.from({ length: 33 }, () => ({ | ||
x: i + 1, | ||
y: i + 1, | ||
z: i + 1, | ||
visibility: 0, | ||
})), | ||
}; | ||
|
||
const onResults = (results) => { | ||
expected = results; | ||
}; | ||
|
||
smoothLandmarks(landmarks, onResults); | ||
} | ||
|
||
// We will test only the 1st entity | ||
expect(expected.poseLandmarks[0]?.x).toEqual(4.5); | ||
}); |