Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/hosted-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Contributors guide: https://github.com/fastify/example#contributions

- [ ] the project has a dedicated folder in `kebab-case`
- [ ] there is not an `index.js`, but a valuable name (usaully the same of the folder)
- [ ] a test example is included (preferring using `tap`)
- [ ] a test example is included (preferring using `node:test`)
- [ ] the internal `README.md` file describe the project itself
- [ ] there are comments on code that explain the most difficult parts
- [ ] the project has been added in the examples list in the root `README.md` of this repository
Expand Down
4 changes: 2 additions & 2 deletions typescript-decorators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"start": "node bin/app.js",
"try-me": "curl http://localhost:3000/main",
"build": "tsc",
"test": "tap"
"pretest": "npm run build",
"test": "node --test \"test/**/*.test.js\""
},
"keywords": [
"typescript",
Expand All @@ -23,7 +24,6 @@
},
"devDependencies": {
"@types/node": "^12.12.24",
"tap": "^14.10.5",
"typescript": "^3.7.4"
}
}
42 changes: 0 additions & 42 deletions typescript-decorators/test/main.controller.spec.ts

This file was deleted.

40 changes: 40 additions & 0 deletions typescript-decorators/test/main.controller.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict'

const assert = require('node:assert/strict')
const { after, test } = require('node:test')
const { instance } = require('../dist/typescript-decorators')

after(() => instance.close())

test('Controller hook should change X-Powered-By header', async () => {
const { headers } = await instance.inject({
url: '/main/',
method: 'GET'
})

assert.equal(headers['x-powered-by'], 'Apache')
})

test('Controller should keep state', async () => {
const firstGetResponse = await instance.inject({
url: '/main/',
method: 'GET'
})

assert.equal(firstGetResponse.payload, '{"message":""}')

const postResponse = await instance.inject({
url: '/main/',
method: 'POST',
payload: { message: 'test' }
})

assert.equal(postResponse.payload, '{"message":"OK"}')

const secondGetResponse = await instance.inject({
url: '/main/',
method: 'GET'
})

assert.equal(secondGetResponse.payload, '{"message":"test"}')
})