{"id":23035544,"url":"https://github.com/ynnjs/ynn-mock","last_synced_at":"2025-04-02T22:40:55.151Z","repository":{"id":57403979,"uuid":"166251879","full_name":"ynnjs/ynn-mock","owner":"ynnjs","description":"Mocking data for Ynn","archived":false,"fork":false,"pushed_at":"2019-02-24T12:11:06.000Z","size":205,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T00:05:18.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ynnjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-17T15:50:15.000Z","updated_at":"2019-02-24T12:11:08.000Z","dependencies_parsed_at":"2022-09-15T20:02:16.028Z","dependency_job_id":null,"html_url":"https://github.com/ynnjs/ynn-mock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynnjs%2Fynn-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynnjs%2Fynn-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynnjs%2Fynn-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynnjs%2Fynn-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ynnjs","download_url":"https://codeload.github.com/ynnjs/ynn-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246905830,"owners_count":20852818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-15T16:45:23.492Z","updated_at":"2025-04-02T22:40:55.125Z","avatar_url":"https://github.com/ynnjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ynn-mock\n\nMocking data for Ynn\n\n## Installation\n\n```sh\n$ npm i --save-dev ynn-mock\n```\n\n## Usage\n\n### mock.rsc\n\nMocking data for RSC request for test cases.\n\n**mock.rsc( app, uri, response )**\n\n**mock.rsc( app, response )**\n\n**mock.rsc.restore( app )**\n\n```js\nconst mock = require( 'ynn-mock' );\n\nconst app = new Ynn( {\n    root : __dirname, \n    debugging : false,\n    logging : false\n} );\n\ndescribe( 'Ynn test', () =\u003e {\n\n    beforeAll( async () =\u003e {\n        await app.ready();\n        await mock.rsc( app, 'service:the/api', { n : 1 } );\n\n        // To mock response data for all URIs.\n        await mock.rsc( app, { n : 2 } );\n    } );\n\n    afterAll( () =\u003e mock.rsc.restore( app ) );\n\n    it( 'should use mock response for \"service:the/api\"', async () =\u003e {\n        const res = app.rsc.call( 'service:the/api' ); \n        expect( res ).toEqual( { n : 1 } ); // pass\n    } );\n\n    it( 'should use mock response which does not specify an URI', async () =\u003e {\n        const res = app.rsc.call( 'api/that/is/not/mock' );\n        expect( res ).toEqual( { n : 2 } ); // pass\n    } );\n} );\n```\n\n### mock.service\n\n```js\nconst mock = require( 'ynn-mock' );\n\ndescribe( 'mock.service', () =\u003e {\n    it( 'desc', async () =\u003e {\n        const app = new Ynn( {\n            root : __dirname,\n            debugging : true,\n            logging : false\n        } );\n\n        await mock.service( app, 'serviceName', {\n            property1 : value,\n            property2 : value\n            ...\n        } )\n\n    } );\n} );\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fynnjs%2Fynn-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fynnjs%2Fynn-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fynnjs%2Fynn-mock/lists"}