Skip to content

Commit

Permalink
upgrade package dependencies and tap 15 migration (#37)
Browse files Browse the repository at this point in the history
* chore: upgrade package dependencies

* refactor (test): tap 15 updates

* refactor (docs): fix a little typo

* fix (example): update `@hotwired/turbo` unpkg link to v7.0.1
  • Loading branch information
darkgl0w authored Oct 25, 2021
1 parent 40b252c commit 336de06
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ts: false
jsx: false
flow: false
coverage: true
check-coverage: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add the plugin to Fastify, with at least two options:

```js
// in your fastify app
fastify .register(require('fastify-hotwire'), {
fastify.register(require('fastify-hotwire'), {
templates: join(__dirname, 'views'),
filename: join(__dirname, 'worker.js')
})
Expand Down
2 changes: 1 addition & 1 deletion example/views/index.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<svelte:head>
<title>demo app</title>
<script src="https://unpkg.com/@hotwired/[email protected].0-beta.4/dist/turbo.es5-umd.js"></script>
<script src="https://unpkg.com/@hotwired/[email protected].1/dist/turbo.es2017-umd.js"></script>
<script>
Turbo.connectStreamSource(new WebSocket(`ws://${document.location.host}/ws`))
</script>
Expand Down
30 changes: 11 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,22 @@
"homepage": "https://github.com/fastify/fastify-hotwire#readme",
"dependencies": {
"fastify-plugin": "^3.0.0",
"piscina": "^3.0.0"
"piscina": "^3.1.0"
},
"devDependencies": {
"@hotwired/turbo": "^7.0.0-beta.4",
"@types/node": "^16.0.0",
"fastify": "^3.12.0",
"fastify-cookie": "^5.1.0",
"fastify-formbody": "^5.0.0",
"@hotwired/turbo": "^7.0.1",
"@types/node": "^16.11.4",
"fastify": "^3.22.1",
"fastify-cookie": "^5.3.1",
"fastify-formbody": "^5.1.0",
"fastify-websocket": "^4.0.0",
"mqemitter": "^4.4.1",
"pino-pretty": "^7.0.0",
"mqemitter": "^4.5.0",
"pino-pretty": "^7.1.0",
"shortid": "^2.2.16",
"standard": "^16.0.3",
"standard": "^16.0.4",
"superheroes": "^3.0.0",
"svelte": "^3.34.0",
"tap": "^14.11.0",
"svelte": "^3.44.0",
"tap": "^15.0.10",
"tsd": "^0.18.0"
},
"tap": {
"esm": false,
"ts": false,
"jsx": false,
"flow": false,
"coverage": false,
"jobs-auto": true
}
}
18 changes: 9 additions & 9 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Hotwire = require('./')

test('Should render the entire page', async t => {
const fastify = Fastify()
fastify.register(Hotwire, {
await fastify.register(Hotwire, {
templates: join(__dirname, 'example', 'views'),
filename: join(__dirname, 'example', 'worker.js')
})
Expand All @@ -21,15 +21,15 @@ test('Should render the entire page', async t => {
path: '/'
})

t.strictEqual(response.statusCode, 200)
t.equal(response.statusCode, 200)
t.match(response.headers, { 'content-type': 'text/html; charset=utf-8' })
t.true(response.payload.includes('foobar'))
t.ok(response.payload.includes('foobar'))
})

function runTurboStream (action) {
test(`Should return a turbo fragment (${action})`, async t => {
const fastify = Fastify()
fastify.register(Hotwire, {
await fastify.register(Hotwire, {
templates: join(__dirname, 'example', 'views'),
filename: join(__dirname, 'example', 'worker.js')
})
Expand All @@ -53,16 +53,16 @@ function runTurboStream (action) {
path: '/'
})

t.strictEqual(response.statusCode, 200)
t.equal(response.statusCode, 200)
t.match(response.headers, { 'content-type': 'text/vnd.turbo-stream.html; charset=utf-8' })
t.strictEqual(response.payload.replace(/\n/g, '').trim(), `<turbo-stream action="${action}" target="messages"> <template> <turbo-frame id="message_frame_unique"><p><strong>foobar:</strong> hello world</p> <form action="/message/unique/delete" method="POST"><button type="submit">Remove</button></form></turbo-frame> </template> </turbo-stream>`)
t.equal(response.payload.replace(/\n/g, '').trim(), `<turbo-stream action="${action}" target="messages"> <template> <turbo-frame id="message_frame_unique"><p><strong>foobar:</strong> hello world</p> <form action="/message/unique/delete" method="POST"><button type="submit">Remove</button></form></turbo-frame> </template> </turbo-stream>`)
})
}

function runTurboGenerate (action) {
test(`Should generate a turbo fragment (${action})`, async t => {
const fastify = Fastify()
fastify.register(Hotwire, {
await fastify.register(Hotwire, {
templates: join(__dirname, 'example', 'views'),
filename: join(__dirname, 'example', 'worker.js')
})
Expand All @@ -87,9 +87,9 @@ function runTurboGenerate (action) {
path: '/'
})

t.strictEqual(response.statusCode, 200)
t.equal(response.statusCode, 200)
t.match(response.headers, { 'content-type': 'text/plain' })
t.strictEqual(response.payload, `<turbo-stream action="${action}" target="messages"> <template> <turbo-frame id="message_frame_unique"><p><strong>foobar:</strong> hello world</p> <form action="/message/unique/delete" method="POST"><button type="submit">Remove</button></form></turbo-frame> </template> </turbo-stream>`)
t.equal(response.payload, `<turbo-stream action="${action}" target="messages"> <template> <turbo-frame id="message_frame_unique"><p><strong>foobar:</strong> hello world</p> <form action="/message/unique/delete" method="POST"><button type="submit">Remove</button></form></turbo-frame> </template> </turbo-stream>`)
})
}

Expand Down

0 comments on commit 336de06

Please sign in to comment.