You've already forked MathDecidr
mirror of
https://github.com/FullScreenShenanigans/MathDecidr.git
synced 2026-04-28 13:02:37 -07:00
9a9a98a608
Also changed constants and equations to be public readonly members, and equations to no longer take constants and equations in. Fixes #1.
37 lines
1019 B
TypeScript
37 lines
1019 B
TypeScript
import { IConstants, IEquation, IEquations, IMathDecidr, IMathDecidrSettings } from "../../src/IMathDecidr";
|
|
import { MathDecidr } from "../../src/MathDecidr";
|
|
|
|
export interface IMockConstants extends IConstants {
|
|
gravity: number;
|
|
}
|
|
|
|
export interface IMockEquations extends IEquations {
|
|
fallingForce: IEquation;
|
|
}
|
|
|
|
export interface IMockMathDecidr extends IMathDecidr {
|
|
readonly constants: IMockConstants;
|
|
readonly equations: IMockEquations;
|
|
}
|
|
|
|
export const mockConstants: IMockConstants = {
|
|
gravity: 9.81
|
|
};
|
|
|
|
export const mockEquations: IMockEquations = {
|
|
fallingForce: function (this: IMockMathDecidr, mass: number): number {
|
|
return mass * this.constants.gravity;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param settings Settings for the
|
|
* @returns A new MathDecidr instance.
|
|
*/
|
|
export function mockMathDecidr(settings?: IMathDecidrSettings): IMockMathDecidr {
|
|
return new MathDecidr(settings || {
|
|
constants: mockConstants,
|
|
equations: mockEquations
|
|
}) as any as IMockMathDecidr;
|
|
}
|