diff --git a/tests/index.test.js b/tests/index.test.js index 6d13bce..7adc68b 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -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); });