-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename Mover component to ScrollBody
- Loading branch information
davidcetinkaya
committed
Feb 23, 2020
1 parent
410c535
commit 5a78809
Showing
8 changed files
with
61 additions
and
57 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,39 +1,43 @@ | ||
import { Mover } from '../components/mover' | ||
import { ScrollBody } from '../components/scrollBody' | ||
import { Vector1D } from '../components/vector1d' | ||
|
||
let mover: Mover | ||
let scrollBody: ScrollBody | ||
let target: Vector1D | ||
|
||
beforeEach(() => { | ||
mover = Mover({ location: Vector1D(0), speed: 10, mass: 1 }) | ||
scrollBody = ScrollBody({ | ||
location: Vector1D(0), | ||
speed: 10, | ||
mass: 1, | ||
}) | ||
target = Vector1D(10) | ||
}) | ||
|
||
describe('Mover', () => { | ||
describe('ScrollBody', () => { | ||
describe('Seek', () => { | ||
test('Seeks given target Vector', () => { | ||
mover.seek(target).update() | ||
expect(mover.location.get()).toBeGreaterThan(0) | ||
scrollBody.seek(target).update() | ||
expect(scrollBody.location.get()).toBeGreaterThan(0) | ||
}) | ||
test('Has direction value of 1 when it seeks given positive target Vector', () => { | ||
mover.seek(target).update() | ||
expect(mover.direction.get()).toBe(1) | ||
scrollBody.seek(target).update() | ||
expect(scrollBody.direction.get()).toBe(1) | ||
}) | ||
test('Has direction value of -1 when it seeks given negative target Vector', () => { | ||
target.setNumber(-10) | ||
mover.seek(target).update() | ||
expect(mover.direction.get()).toBe(-1) | ||
scrollBody.seek(target).update() | ||
expect(scrollBody.direction.get()).toBe(-1) | ||
}) | ||
}) | ||
|
||
describe('Settle', () => { | ||
test('Settle is true when diff to given target Vector is <= 0.001', () => { | ||
mover.location.setNumber(9.999) | ||
expect(mover.settle(target)).toBe(true) | ||
scrollBody.location.setNumber(9.999) | ||
expect(scrollBody.settle(target)).toBe(true) | ||
}) | ||
test('Settle is false when diff to given target Vector is > 0.001', () => { | ||
mover.location.setNumber(9.99) | ||
expect(mover.settle(target)).toBe(false) | ||
scrollBody.location.setNumber(9.99) | ||
expect(scrollBody.settle(target)).toBe(false) | ||
}) | ||
}) | ||
}) |
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
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