Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ynnjs/ynn-mock
Mocking data for Ynn
https://github.com/ynnjs/ynn-mock
Last synced: 25 days ago
JSON representation
Mocking data for Ynn
- Host: GitHub
- URL: https://github.com/ynnjs/ynn-mock
- Owner: ynnjs
- License: mit
- Created: 2019-01-17T15:50:15.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-24T12:11:06.000Z (almost 6 years ago)
- Last Synced: 2024-11-22T05:35:41.308Z (about 2 months ago)
- Language: JavaScript
- Size: 200 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ynn-mock
Mocking data for Ynn
## Installation
```sh
$ npm i --save-dev ynn-mock
```## Usage
### mock.rsc
Mocking data for RSC request for test cases.
**mock.rsc( app, uri, response )**
**mock.rsc( app, response )**
**mock.rsc.restore( app )**
```js
const mock = require( 'ynn-mock' );const app = new Ynn( {
root : __dirname,
debugging : false,
logging : false
} );describe( 'Ynn test', () => {
beforeAll( async () => {
await app.ready();
await mock.rsc( app, 'service:the/api', { n : 1 } );// To mock response data for all URIs.
await mock.rsc( app, { n : 2 } );
} );afterAll( () => mock.rsc.restore( app ) );
it( 'should use mock response for "service:the/api"', async () => {
const res = app.rsc.call( 'service:the/api' );
expect( res ).toEqual( { n : 1 } ); // pass
} );it( 'should use mock response which does not specify an URI', async () => {
const res = app.rsc.call( 'api/that/is/not/mock' );
expect( res ).toEqual( { n : 2 } ); // pass
} );
} );
```### mock.service
```js
const mock = require( 'ynn-mock' );describe( 'mock.service', () => {
it( 'desc', async () => {
const app = new Ynn( {
root : __dirname,
debugging : true,
logging : false
} );await mock.service( app, 'serviceName', {
property1 : value,
property2 : value
...
} )} );
} );
```