roschaefer 7c6d5b5129 fix: Re-enable webfinger feature
Ok, so here is the plan. Let's give both our cucumber features and your
cypress tests a prominent place to live. That would be the root level
folder of our application. Second, let's revive formerly dead code step
by step.

Ie. move code from the former location `backend/features/` to `features/`
when it is ready. All edge cases should be tested with unit tests in
`backend/`, see my `webfinger.spec.js` as an example.
2019-12-02 17:31:56 +01:00

46 lines
1.3 KiB
JavaScript

// features/support/steps.js
import { Given, When, Then, After, AfterAll } from 'cucumber'
import Factory from '../../backend/src/seed/factories'
import dotenv from 'dotenv'
import expect from 'expect'
const debug = require('debug')('ea:test:steps')
const factory = Factory()
After(async () => {
await factory.cleanDatabase()
})
Given('our CLIENT_URI is {string}', function (string) {
expect(process.env.CLIENT_URI).toEqual(string)
});
Given('we have the following users in our database:', function (dataTable) {
return Promise.all(dataTable.hashes().map(({ slug, name }) => {
return factory.create('User', {
name,
slug,
})
}))
})
When('I send a GET request to {string}', async function (pathname) {
const response = await this.get(pathname)
this.lastContentType = response.lastContentType
this.lastResponses.push(response.lastResponse)
this.statusCode = response.statusCode
})
Then('the server responds with a HTTP Status {int} and the following json:', function (statusCode, docString) {
expect(this.statusCode).toEqual(statusCode)
const [ lastResponse ] = this.lastResponses
expect(JSON.parse(lastResponse)).toMatchObject(JSON.parse(docString))
})
Then('the Content-Type is {string}', function (contentType) {
expect(this.lastContentType).toEqual(contentType)
})