-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Gives us a place to put testing utilities. I also expect to put `useMockedRAF` here, removing the need for `waitAFrame`. That work is currently blocked on the landing of FormidableLabs/mock-raf#6 If that doesn't land, I'll fork mock-raf and add it here too. Reviewers: O3 Material JavaScript platform reviewers, #material_motion, O2 Material Motion, featherless Reviewed By: #material_motion, O2 Material Motion, featherless Tags: #material_motion Differential Revision: http://codereview.cc/D2411
- Loading branch information
1 parent
b353d28
commit c5d8089
Showing
5 changed files
with
135 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Material Motion Testing Utils # | ||
|
||
Utilities for testing the Material Motion framework | ||
|
||
## Usage ## | ||
|
||
```javascript | ||
import { | ||
createMockObserver, | ||
} from 'material-motion-testing-utils'; | ||
|
||
const mockObserver = createMockObserver(); | ||
|
||
const someStream = new MotionObservable(mockObserver); | ||
someStream.subscribe(someListener); | ||
mockObserver.next(5); | ||
expect(someListener).to.have.been.calledWith(5); | ||
``` | ||
|
||
## Installation ## | ||
|
||
``` | ||
yarn add material-motion-testing-utils | ||
``` | ||
|
||
## License ## | ||
|
||
[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) |
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,39 @@ | ||
{ | ||
"name": "material-motion-testing-utils", | ||
"version": "0.0.0", | ||
"description": "Utilities for testing the Material Motion framework", | ||
"main": "dist/index.js", | ||
"types": "src/index.ts", | ||
"scripts": { | ||
"clean": "rm -rf ./dist/*; mkdir -p ./dist/", | ||
"build": "yarn run clean; ../../node_modules/.bin/tsc" | ||
}, | ||
"peerDependencies": { | ||
"sinon": "2.0.0-pre.3" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com:material-motion/material-motion-js.git" | ||
}, | ||
"keywords": [ | ||
"animation", | ||
"gestures", | ||
"interactive", | ||
"material", | ||
"motion", | ||
"multitouch", | ||
"observables", | ||
"odeon", | ||
"physics", | ||
"springs", | ||
"touch", | ||
"transitions", | ||
"tweens" | ||
], | ||
"author": "The Material Motion Authors (see AUTHORS)", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/material-motion/material-motion-js/issues/" | ||
}, | ||
"homepage": "https://github.com/material-motion/material-motion-js/tree/develop/packages/testing-utils/#readme" | ||
} |
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,36 @@ | ||
/** @license | ||
* Copyright 2016 - present The Material Motion Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { | ||
stub, | ||
} from 'sinon'; | ||
|
||
export default function createMockObserver() { | ||
return new MockObserver(); | ||
} | ||
|
||
export class MockObserver { | ||
next?: Function; | ||
state?: Function; | ||
disconnect = stub(); | ||
|
||
connect = (observer) => { | ||
this.next = observer.next; | ||
this.state = observer.state; | ||
|
||
return this.disconnect; | ||
} | ||
} |
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,18 @@ | ||
/** @license | ||
* Copyright 2016 - present The Material Motion Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export * from './createMockObserver'; | ||
export { default as createMockObserver } from './createMockObserver'; |
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,14 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["./src/**/*"], | ||
"exclude": [], | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "src", | ||
"noImplicitAny": false, | ||
"noImplicitThis": false, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"strictNullChecks": false | ||
} | ||
} |