Skip to content

Commit ae24c58

Browse files
authored
Merge pull request #583 from tweenjs/convert-tests-to-typescript
chore: convert test code to TypeScript
2 parents 25452ca + c6db2ab commit ae24c58

File tree

7 files changed

+1956
-1961
lines changed

7 files changed

+1956
-1961
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,13 @@ You need to install `npm` first--this comes with node.js, so install that one fi
239239
npm install
240240
```
241241

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

244244
```bash
245245
npm test
246246
```
247247

248-
every time you want to run the tests.
249-
250-
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.
248+
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.
251249

252250
## People
253251

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"tsc": "tsc",
3232
"tsc-watch": "tsc --watch",
3333
"examples": "npx serve .",
34-
"test": "npm run build && npm run test-unit && npm run test-lint",
34+
"test": "npm run build && npm run test-lint && npm run test-unit",
3535
"test-unit": "nodeunit test/unit/nodeunitheadless.js",
3636
"test-lint": "npm run prettier -- --check && eslint 'src/**/*.ts'",
3737
"lint": "npm run prettier -- --write && eslint 'src/**/*.ts' --fix",

rollup.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ export default [
3030
},
3131
],
3232
},
33+
{
34+
input: '.tmp/tests.js',
35+
context: 'this',
36+
watch: {clearScreen: false},
37+
output: [{file: '.tmp/tests.cjs.js', format: 'cjs', exports: 'named'}],
38+
},
3339
{
3440
input: './.tmp/Index.d.ts',
3541
watch: {clearScreen: false},

src/Tween.ts

+17-15
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export class Tween<T extends UnknownProps> {
3434
private _startTime = 0
3535
private _easingFunction: EasingFunction = Easing.Linear.None
3636
private _interpolationFunction: InterpolationFunction = Interpolation.Linear
37-
private _chainedTweens: Array<Tween<UnknownProps>> = []
37+
// eslint-disable-next-line
38+
private _chainedTweens: Array<Tween<any>> = []
3839
private _onStartCallback?: (object: T) => void
3940
private _onStartCallbackFired = false
4041
private _onUpdateCallback?: (object: T, elapsed: number) => void
@@ -72,7 +73,7 @@ export class Tween<T extends UnknownProps> {
7273
return this
7374
}
7475

75-
duration(d: number): this {
76+
duration(d = 1000): this {
7677
this._duration = d
7778
return this
7879
}
@@ -256,68 +257,69 @@ export class Tween<T extends UnknownProps> {
256257
return this
257258
}
258259

259-
group(group: Group): this {
260+
group(group = mainGroup): this {
260261
this._group = group
261262
return this
262263
}
263264

264-
delay(amount: number): this {
265+
delay(amount = 0): this {
265266
this._delayTime = amount
266267
return this
267268
}
268269

269-
repeat(times: number): this {
270+
repeat(times = 0): this {
270271
this._initialRepeat = times
271272
this._repeat = times
272273
return this
273274
}
274275

275-
repeatDelay(amount: number): this {
276+
repeatDelay(amount?: number): this {
276277
this._repeatDelayTime = amount
277278
return this
278279
}
279280

280-
yoyo(yoyo: boolean): this {
281+
yoyo(yoyo = false): this {
281282
this._yoyo = yoyo
282283
return this
283284
}
284285

285-
easing(easingFunction: EasingFunction): this {
286+
easing(easingFunction: EasingFunction = Easing.Linear.None): this {
286287
this._easingFunction = easingFunction
287288
return this
288289
}
289290

290-
interpolation(interpolationFunction: InterpolationFunction): this {
291+
interpolation(interpolationFunction: InterpolationFunction = Interpolation.Linear): this {
291292
this._interpolationFunction = interpolationFunction
292293
return this
293294
}
294295

295-
chain(...tweens: Array<Tween<UnknownProps>>): this {
296+
// eslint-disable-next-line
297+
chain(...tweens: Array<Tween<any>>): this {
296298
this._chainedTweens = tweens
297299
return this
298300
}
299301

300-
onStart(callback: (object: T) => void): this {
302+
onStart(callback?: (object: T) => void): this {
301303
this._onStartCallback = callback
302304
return this
303305
}
304306

305-
onUpdate(callback: (object: T, elapsed: number) => void): this {
307+
onUpdate(callback?: (object: T, elapsed: number) => void): this {
306308
this._onUpdateCallback = callback
307309
return this
308310
}
309311

310-
onRepeat(callback: (object: T) => void): this {
312+
onRepeat(callback?: (object: T) => void): this {
311313
this._onRepeatCallback = callback
312314
return this
313315
}
314316

315-
onComplete(callback: (object: T) => void): this {
317+
onComplete(callback?: (object: T) => void): this {
316318
this._onCompleteCallback = callback
317319
return this
318320
}
319321

320-
onStop(callback: (object: T) => void): this {
322+
onStop(callback?: (object: T) => void): this {
321323
this._onStopCallback = callback
322324
return this
323325
}

0 commit comments

Comments
 (0)