mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
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.
39 lines
944 B
JavaScript
39 lines
944 B
JavaScript
import { setWorldConstructor } from 'cucumber'
|
|
import request from 'request'
|
|
|
|
class CustomWorld {
|
|
constructor () {
|
|
// webFinger.feature
|
|
this.lastResponses = []
|
|
this.lastContentType = null
|
|
this.lastInboxUrl = null
|
|
this.lastActivity = null
|
|
// object-article.feature
|
|
this.statusCode = null
|
|
}
|
|
get (pathname) {
|
|
return new Promise((resolve, reject) => {
|
|
request(`http://localhost:4000/${this.replaceSlashes(pathname)}`, {
|
|
headers: {
|
|
'Accept': 'application/activity+json'
|
|
}}, (error, response, body) => {
|
|
if (!error) {
|
|
resolve({
|
|
lastResponse: body,
|
|
lastContentType: response.headers['content-type'],
|
|
statusCode: response.statusCode
|
|
})
|
|
} else {
|
|
reject(error)
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
replaceSlashes (pathname) {
|
|
return pathname.replace(/^\/+/, '')
|
|
}
|
|
}
|
|
|
|
setWorldConstructor(CustomWorld)
|