Skip to content

Commit

Permalink
bug: closes bracket if default switch template builder
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeSV committed Nov 2, 2023
1 parent c687e04 commit 1490e0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/handlers/migrationHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,11 @@ describe('migrationHandler', () => {
"await db.schema\n\t\t.alterTable('todo')\n\t\t.addColumn('complete', 'boolean', (col) => col.notNull())\n\t\t.execute()"
)
})
it('adds an end if cant find the action', () => {
const template = generateTemplate('do_stuff', []).getTemplate()
expect(template).toContain(
"import { Migration } from 'kysely'\n\nexport const up: Migration['up'] = async (db) => {\n}\n\nexport const down: Migration['down'] = async (db) => {\n}\n\n"
)
})
})
})
6 changes: 5 additions & 1 deletion src/handlers/migrationHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const parseInput = (input: string) => {
const inputParts = input.split('_')
const type = inputParts[0]
let tableName
if (type == Commands.CreateTable) {
if (type === Commands.CreateTable) {
tableName = inputParts[1]
} else {
tableName = inputParts[inputParts.length - 1]
Expand Down Expand Up @@ -87,6 +87,10 @@ export const generateTemplate = (
}
)
break

default:
b.addEnd()
break
}

b.addDown().addEnd()
Expand Down

0 comments on commit 1490e0c

Please sign in to comment.