Skip to content

Commit

Permalink
Adding a couple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay committed Mar 19, 2024
1 parent 08cbb59 commit 40e42f1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, test, expect } from "vitest";

import { mirabuf } from "../../proto/mirabuf";
import MirabufParser, { RigidNodeReadOnly } from "../../mirabuf/MirabufParser";
import { LoadMirabufLocal } from "../../mirabuf/MirabufLoader";
import { mirabuf } from "../proto/mirabuf";
import MirabufParser, { RigidNodeReadOnly } from "../mirabuf/MirabufParser";
import { LoadMirabufLocal } from "../mirabuf/MirabufLoader";

describe('Mirabuf Parser Tests', () => {
// test('Get Dozer JSON', () => {
Expand Down
24 changes: 23 additions & 1 deletion fission/src/test/PhysicsSystem.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect, describe, assert } from 'vitest';
import PhysicsSystem from '../systems/physics/PhysicsSystem';
import { LoadMirabufLocal } from '@/mirabuf/MirabufLoader';
import MirabufParser from '@/mirabuf/MirabufParser';

describe('Physics System Tests', () => {
describe('Physics Sansity Checks', () => {
test('Convex Hull Shape (Cube)', () => {
const points: Float32Array = new Float32Array(
[
Expand Down Expand Up @@ -60,4 +62,24 @@ describe('Physics System Tests', () => {
shape.Release();
system.Destroy();
});
});

describe('Mirabuf Body Loading', () => {
test('Body Loading (Dozer)', () => {
const assembly = LoadMirabufLocal('./public/test_mira/Dozer_v2.mira');
const parser = new MirabufParser(assembly);
const physSystem = new PhysicsSystem();
const mapping = physSystem.CreateBodiesFromParser(parser);

expect(mapping.size).toBe(7);
});

test('Body Loading (Team_2471_(2018)_v7.mira)', () => {
const assembly = LoadMirabufLocal('./public/test_mira/Team_2471_(2018)_v7.mira');
const parser = new MirabufParser(assembly);
const physSystem = new PhysicsSystem();
const mapping = physSystem.CreateBodiesFromParser(parser);

expect(mapping.size).toBe(10);
});
});
19 changes: 19 additions & 0 deletions fission/src/test/World.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import World from "@/systems/World";
import { describe, test, expect, beforeEach, vi } from "vitest";

describe('World Tests', () => {

beforeEach(() => {
vi.resetAllMocks();
});

test('World Sanity Check', () => {
expect(World.isAlive).toBeFalsy();

// TODO: Find a way to mock window global
// World.InitWorld();
// expect(World.isAlive).toBeTruthy();
// expect(World.SceneRenderer).toBeTruthy();
// expect(World.DestroyWorld).toBeTruthy();
});
})

0 comments on commit 40e42f1

Please sign in to comment.