Skip to content

Commit

Permalink
Merge pull request #583 from tweenjs/convert-tests-to-typescript
Browse files Browse the repository at this point in the history
chore: convert test code to TypeScript
  • Loading branch information
trusktr committed Oct 23, 2020
2 parents 25452ca + c6db2ab commit ae24c58
Show file tree
Hide file tree
Showing 7 changed files with 1,956 additions and 1,961 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,13 @@ You need to install `npm` first--this comes with node.js, so install that one fi
npm install
```

if running the tests for the first time, to install additional dependencies for running tests, and then run
To run the tests run:

```bash
npm test
```

every time you want to run the tests.

If you want to add any feature or change existing features, you _must_ run the tests to make sure you didn't break anything else. If you send a pull request (PR) to add something new and it doesn't have tests, or the tests don't pass, the PR won't be accepted. See [contributing](CONTRIBUTING.md) for more information.
If you want to add any feature or change existing features, you _must_ run the tests to make sure you didn't break anything else. Any pull request (PR) needs to have updated passing tests for feature changes (or new passing tests for new features) in `src/tests.ts`, otherwise the PR won't be accepted. See [contributing](CONTRIBUTING.md) for more information.

## People

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"tsc": "tsc",
"tsc-watch": "tsc --watch",
"examples": "npx serve .",
"test": "npm run build && npm run test-unit && npm run test-lint",
"test": "npm run build && npm run test-lint && npm run test-unit",
"test-unit": "nodeunit test/unit/nodeunitheadless.js",
"test-lint": "npm run prettier -- --check && eslint 'src/**/*.ts'",
"lint": "npm run prettier -- --write && eslint 'src/**/*.ts' --fix",
Expand Down
6 changes: 6 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export default [
},
],
},
{
input: '.tmp/tests.js',
context: 'this',
watch: {clearScreen: false},
output: [{file: '.tmp/tests.cjs.js', format: 'cjs', exports: 'named'}],
},
{
input: './.tmp/Index.d.ts',
watch: {clearScreen: false},
Expand Down
32 changes: 17 additions & 15 deletions src/Tween.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export class Tween<T extends UnknownProps> {
private _startTime = 0
private _easingFunction: EasingFunction = Easing.Linear.None
private _interpolationFunction: InterpolationFunction = Interpolation.Linear
private _chainedTweens: Array<Tween<UnknownProps>> = []
// eslint-disable-next-line
private _chainedTweens: Array<Tween<any>> = []
private _onStartCallback?: (object: T) => void
private _onStartCallbackFired = false
private _onUpdateCallback?: (object: T, elapsed: number) => void
Expand Down Expand Up @@ -72,7 +73,7 @@ export class Tween<T extends UnknownProps> {
return this
}

duration(d: number): this {
duration(d = 1000): this {
this._duration = d
return this
}
Expand Down Expand Up @@ -256,68 +257,69 @@ export class Tween<T extends UnknownProps> {
return this
}

group(group: Group): this {
group(group = mainGroup): this {
this._group = group
return this
}

delay(amount: number): this {
delay(amount = 0): this {
this._delayTime = amount
return this
}

repeat(times: number): this {
repeat(times = 0): this {
this._initialRepeat = times
this._repeat = times
return this
}

repeatDelay(amount: number): this {
repeatDelay(amount?: number): this {
this._repeatDelayTime = amount
return this
}

yoyo(yoyo: boolean): this {
yoyo(yoyo = false): this {
this._yoyo = yoyo
return this
}

easing(easingFunction: EasingFunction): this {
easing(easingFunction: EasingFunction = Easing.Linear.None): this {
this._easingFunction = easingFunction
return this
}

interpolation(interpolationFunction: InterpolationFunction): this {
interpolation(interpolationFunction: InterpolationFunction = Interpolation.Linear): this {
this._interpolationFunction = interpolationFunction
return this
}

chain(...tweens: Array<Tween<UnknownProps>>): this {
// eslint-disable-next-line
chain(...tweens: Array<Tween<any>>): this {
this._chainedTweens = tweens
return this
}

onStart(callback: (object: T) => void): this {
onStart(callback?: (object: T) => void): this {
this._onStartCallback = callback
return this
}

onUpdate(callback: (object: T, elapsed: number) => void): this {
onUpdate(callback?: (object: T, elapsed: number) => void): this {
this._onUpdateCallback = callback
return this
}

onRepeat(callback: (object: T) => void): this {
onRepeat(callback?: (object: T) => void): this {
this._onRepeatCallback = callback
return this
}

onComplete(callback: (object: T) => void): this {
onComplete(callback?: (object: T) => void): this {
this._onCompleteCallback = callback
return this
}

onStop(callback: (object: T) => void): this {
onStop(callback?: (object: T) => void): this {
this._onStopCallback = callback
return this
}
Expand Down
Loading

0 comments on commit ae24c58

Please sign in to comment.