Skip to content

Commit

Permalink
🔧 fix: disable remove comment
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom committed Sep 20, 2023
1 parent 9065474 commit dcba09e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
36 changes: 34 additions & 2 deletions test/units/merge-deep.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { describe, expect, it } from 'bun:test'

import { Elysia } from '../../src'
import { mergeDeep } from '../../src'
import { req } from '../utils'

describe('mergeDeep', () => {
it('merge empty object', () => {
Expand Down Expand Up @@ -33,7 +35,7 @@ describe('mergeDeep', () => {
})
})

it('Maintain overlapping class', () => {
it('maintain overlapping class', () => {
class Test {
readonly name = 'test'

Expand All @@ -43,9 +45,39 @@ describe('mergeDeep', () => {
}

const target = { key1: Test }
const source = { key1: Test }
const source = { key2: Test }

const result = mergeDeep(target, source)
expect(result.key1).toBe(Test)
})

it('maintain overlapping class in instance', async () => {
class DbConnection {
health() {
return 'ok'
}

getUsers() {
return []
}
}

const dbPlugin = new Elysia({ name: 'db' }).decorate(
'db',
new DbConnection()
)

const userRoutes = new Elysia({ prefix: '/user' })
.use(dbPlugin)
.get('', ({ db }) => db.getUsers())

const app = new Elysia()
.use(dbPlugin)
.use(userRoutes)
.get('/health', ({ db }) => db.health())

const response = await app.handle(req('/health')).then((x) => x.text())

expect(response).toBe('ok')
})
})
2 changes: 1 addition & 1 deletion tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist/cjs", /* Specify an output folder for all emitted files. */
"removeComments": true, /* Disable emitting comments. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
"removeComments": true, /* Disable emitting comments. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
Expand Down

0 comments on commit dcba09e

Please sign in to comment.