@rvoh/psychic-spec-helpers
TypeScript icon, indicating that this package has built-in type declarations

0.6.1 • Public • Published

Psychic spec helpers

This repo provides spec helpers to be used in conjunction with the psychic web framework.

Getting started

  1. Add this repo as a dev dependency in your psychic project (this is done by default for psychic apps, but worth mentioning in case it has been removed from your repo).
yarn add --dev @rvohealth/psychic-spec-helpers
  1. import psychic spec helpers in your jest setup. This is automatically set up when provisioning a new psychic app, so you should only need to do this with an a-typical setup.
// spec/unit/setup/hooks.ts
import "@rvohealth/psychic-spec-helpers";
...
  1. import and use the provided spec helpers:
import { specRequest as request } from '@rvohealth/psychic-spec-helpers'
import { PsychicController } from '@rvohealth/psychic'

describe('V1/Host/PlacesController', () => {
  let user: User
  let host: Host

  beforeEach(async () => {
    await request.init(PsychicServer)
    user = await createUser()
  })

  describe('GET index', () => {
    function subject(expectedStatus: number = 200) {
      return request.get('/v1/host/places', expectedStatus, {
        headers: addEndUserAuthHeader(request, user, {}),
      })
    }

    it('returns the index of Places', async () => {
      const place = await createPlace({ style: 'cabin', name: 'My cabin' })
      await createHostPlace({ host, place })
      const results = (await subject()).body

      expect(results).toEqual([
        expect.objectContaining({
          id: place.id,
          style: 'cabin',
          name: 'My cabin',
        }),
      ])
    })
  })
})

Questions?

Contributing

Psychic is an open source library, so we encourage you to actively contribute. Visit our Contributing guide to learn more about the processes we use for submitting pull requests or issues.

Are you trying to report a possible security vulnerability? Visit our Security Policy for guidelines about how to proceed.

Readme

Keywords

none

Package Sidebar

Install

npm i @rvoh/psychic-spec-helpers

Weekly Downloads

711

Version

0.6.1

License

none

Unpacked Size

162 kB

Total Files

261

Last publish

Collaborators

  • alex.aavang
  • avocadojesus
  • b_l_u_e_j_a_d_e