-
Notifications
You must be signed in to change notification settings - Fork 0
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
5e8fd3d
commit a6dc577
Showing
8 changed files
with
81 additions
and
16 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
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,8 +1,8 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} **/ | ||
// eslint-disable-next-line no-undef | ||
module.exports = { | ||
testEnvironment: "node", | ||
testEnvironment: 'node', | ||
transform: { | ||
"^.+.tsx?$": ["ts-jest", {}], | ||
'^.+.tsx?$': ['ts-jest', {}], | ||
}, | ||
} |
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 |
---|---|---|
|
@@ -17,7 +17,6 @@ export default { | |
sourcemap: true | ||
} | ||
], | ||
external: ['node:events'], | ||
plugins: [ | ||
typescript() | ||
] | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Body from './Body' | ||
import Simulation from './Simulation' | ||
import Vector from './Vector' | ||
|
||
describe('Simulation', () => { | ||
it('should call changeCallback', async () => { | ||
let resolver: (value?: unknown) => void | ||
const promise = new Promise((resolve) => { resolver = resolve }) | ||
|
||
const simulation = new Simulation({ | ||
bodies: [], | ||
renderInterval: 0, | ||
changeCallback: () => { resolver() } | ||
}) | ||
|
||
await promise | ||
simulation.stop() | ||
}) | ||
|
||
it('should move bodies through universe', async () => { | ||
let resolver: (value?: unknown) => void | ||
const promise = new Promise((resolve) => { resolver = resolve }) | ||
|
||
const startingPositions = [ | ||
new Vector(1, 1, 1), | ||
new Vector(-1, -1, -1) | ||
] | ||
|
||
const simulation = new Simulation({ | ||
bodies: [ | ||
new Body({ | ||
position: startingPositions[0], | ||
velocity: new Vector(0, 0, 0) | ||
}), | ||
new Body({ | ||
position: startingPositions[1], | ||
velocity: new Vector(0, 0, 0) | ||
}) | ||
], | ||
renderInterval: 0, | ||
changeCallback: () => { resolver() } | ||
}) | ||
|
||
expect(simulation.bodies).toBe(simulation.universe.bodies) | ||
|
||
await promise | ||
simulation.stop() | ||
|
||
expect(simulation.bodies[0].position).not.toEqual(startingPositions[0]) | ||
expect(simulation.bodies[1].position).not.toEqual(startingPositions[1]) | ||
}) | ||
}) |
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
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
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