Skip to content

Commit

Permalink
Test cases added
Browse files Browse the repository at this point in the history
  • Loading branch information
yousufkalim committed Dec 15, 2022
1 parent f4a60e6 commit 8fe6b6f
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions tests/index.test.js
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);
});

0 comments on commit 8fe6b6f

Please sign in to comment.