Skip to content

Commit

Permalink
test: migrate from tap to node:test and c8 (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
dancastillo authored Dec 2, 2024
1 parent 635730c commit d49a057
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
8 changes: 0 additions & 8 deletions .taprc

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "standard",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:unit": "tap"
"test:unit": "c8 -100 node --test"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -39,14 +39,14 @@
"@fastify/websocket": "^11.0.1",
"@hotwired/turbo": "^8.0.10",
"@types/node": "^22.5.5",
"c8": "^10.1.2",
"fastify": "^5.0.0",
"mqemitter": "^6.0.2",
"pino-pretty": "^13.0.0",
"shortid": "^2.2.16",
"standard": "^17.0.0",
"superheroes": "^4.0.0",
"svelte": "^3.44.0",
"tap": "^16.0.0",
"tsd": "^0.31.2"
},
"publishConfig": {
Expand Down
20 changes: 10 additions & 10 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { join } = require('node:path')
const { test } = require('tap')
const { test } = require('node:test')
const Fastify = require('fastify')
const Hotwire = require('..')

Expand All @@ -21,9 +21,9 @@ test('Should render the entire page', async t => {
path: '/'
})

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

function runTurboStream (action) {
Expand Down Expand Up @@ -53,9 +53,9 @@ function runTurboStream (action) {
path: '/'
})

t.equal(response.statusCode, 200)
t.match(response.headers, { 'content-type': 'text/vnd.turbo-stream.html; charset=utf-8' })
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>`)
t.assert.strictEqual(response.statusCode, 200)
t.assert.strictEqual(response.headers['content-type'], 'text/vnd.turbo-stream.html; charset=utf-8')
t.assert.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>`)
})
}

Expand Down Expand Up @@ -87,9 +87,9 @@ function runTurboGenerate (action) {
path: '/'
})

t.equal(response.statusCode, 200)
t.match(response.headers, { 'content-type': 'text/plain' })
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>`)
t.assert.strictEqual(response.statusCode, 200)
t.assert.strictEqual(response.headers['content-type'], 'text/plain')
t.assert.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>`)
})
}

Expand Down

0 comments on commit d49a057

Please sign in to comment.