MCPcopy
hub / github.com/tinyhttp/tinyhttp / createColorTest

Function createColorTest

__tests__/wares/logger.test.ts:55–77  ·  view source on GitHub ↗
(status, color, done)

Source from the content-addressed store, hash-verified

53
54 describe('Color logs', () => {
55 const createColorTest = (status, color, done) => {
56 return async () => {
57 const customOutput = (log: string) => {
58 if (color === 'cyan') {
59 expect(log.split(' ')[1]).toMatch(cyan(bold(status).toString()))
60 } else if (color === 'red') {
61 expect(log.split(' ')[1]).toMatch(red(bold(status).toString()))
62 } else if (color === 'magenta') {
63 expect(log.split(' ')[1]).toMatch(magenta(bold(status).toString()))
64 }
65 done()
66 }
67
68 const app = new App()
69
70 app.use(logger({ output: { callback: customOutput, color: true } }))
71 app.get('/', (_, res) => res.status(status).send(''))
72
73 const server = app.listen()
74
75 await makeFetch(server)('/').expect(status)
76 }
77 }
78
79 it('should color 2xx cyan', (done) => {
80 createColorTest(200, 'cyan', done)()

Callers 1

logger.test.tsFile · 0.85

Calls 6

useMethod · 0.95
listenMethod · 0.95
loggerFunction · 0.90
sendMethod · 0.80
statusMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected