https://github.com/eyedea-io/syncano-test
https://github.com/eyedea-io/syncano-test
socket syncano
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/eyedea-io/syncano-test
- Owner: eyedea-io
- License: mit
- Created: 2020-01-24T19:50:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T05:40:13.000Z (over 3 years ago)
- Last Synced: 2024-08-09T18:33:56.750Z (almost 2 years ago)
- Topics: socket, syncano
- Language: JavaScript
- Size: 1.33 MB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @eyedea/syncano-test
Test solution for syncano socket based on [@eyedea/syncano](https://github.com/eyedea-io/syncano).
[](https://www.npmjs.com/package/@eyedea/syncano-test)
[](https://github.com/eyedea-io/syncano-test/blob/master/LICENSE)
## Install
Install package in your socket directory:
```
$ npm install -D @eyedea/syncano-test
```
> It is recommended to install this package as dev dependency, otherwise a lot of unnecessary packages will be deployed with socket.
## Usage
1. Create `__tests__` directory in your socket. Add `__tests__/tsconfig.json` with the following content:
```json
{
"compilerOptions": {
"lib": ["ES2015"]
}
}
```
2. Create your test file `__tests__/ENDPOINT-NAME.test.js`
```tsx
import {run, stub, createSyncanoCoreMock} from '@eyedea/syncano'
describe('SOCKET/ENDPOINT-NAME', () => {
it('should not fail', async () => {
const meta = {user: undefined}
const args = {id: 1}
const mocks = createSyncanoCoreMock({
data: {
entity: {
create: stub().resolves(args)
fields: stub().fn({
with: stub().fn({
findOrFail: stub().resolves(args)
})
})
}
}
})
const result = await run('ENDPOINT-NAME', {args, meta}, {mocks})
expect(result).toHaveProperty('data.id', args.id)
expect(result).toHaveProperty('code', 200)
})
})
```
## License
MIT © Eyedea AS