Skip to content

Commit

Permalink
Add test in typescript.ts for PRIMARY KEY/UNIQUE definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpf committed Feb 19, 2018
1 parent 8b84ad8 commit 6e4ea8e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/unit/typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ describe('Typescript', () => {
'\n }' +
'\n ')
})
it('with primary key and unique column definitions', () => {
const tableTypes = Typescript.generateTableTypes('tableName', {
col1: {udtName: 'name1', nullable: true, tsType: 'string', primaryKey: true, unique: false},
col2: {udtName: 'name2', nullable: true, tsType: 'number', primaryKey: false, unique: true},
col3: {udtName: 'name3', nullable: false, tsType: 'number', unique: false}
}, options)
assert.equal(tableTypes,
'\n' +
' export namespace tableNameFields {' +
'\n export type col1 = {type: string| null,primaryKey: true,unique: false,};' +
'\nexport type col2 = {type: number| null,primaryKey: false,unique: true,};' +
'\nexport type col3 = {type: number| null,unique: false,};' +
'\n' +
'\n }' +
'\n ')
Expand Down

0 comments on commit 6e4ea8e

Please sign in to comment.