Skip to content

Commit

Permalink
chore: adding statement tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonShin committed Aug 26, 2023
1 parent 6b01ae3 commit 7a6008d
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 42 deletions.
31 changes: 31 additions & 0 deletions tests/demo/typescript/statement/function.queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


export type FunctionAssignParams = [];


export interface IFunctionAssignResult {
id: number;
};


export interface IFunctionAssignQuery {
params: FunctionAssignParams;
result: IFunctionAssignResult;
};




export type ReturnQueryParams = [];


export interface IReturnQueryResult {
id: number;
};


export interface IReturnQueryQuery {
params: ReturnQueryParams;
result: IReturnQueryResult;
};

10 changes: 10 additions & 0 deletions tests/demo/typescript/statement/function.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { sql } from 'sqlx-ts'

function test() {
const functionAssign = sql`SELECT id FROM items`

return sql`
-- @name: return query
SELECT id FROM items
`;
}
31 changes: 31 additions & 0 deletions tests/demo/typescript/statement/if.queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


export type IfstmtParams = [];


export interface IIfstmtResult {
id: number;
};


export interface IIfstmtQuery {
params: IfstmtParams;
result: IIfstmtResult;
};




export type NestedIfStmtParams = [];


export interface INestedIfStmtResult {
id: number;
};


export interface INestedIfStmtQuery {
params: NestedIfStmtParams;
result: INestedIfStmtResult;
};

11 changes: 11 additions & 0 deletions tests/demo/typescript/statement/if.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { sql } from 'sqlx-ts'

if (true) {
const ifstmt = sql`SELECT id FROM items;`;
}

function testIfStatement() {
if (true) {
const nestedIfStmt = sql`SELECT id FROM items;`;
}
}
31 changes: 31 additions & 0 deletions tests/demo/typescript/statement/switch.queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


export type Case1Params = [];


export interface ICase1Result {
id: number;
};


export interface ICase1Query {
params: Case1Params;
result: ICase1Result;
};




export type Case2Params = [];


export interface ICase2Result {
id: number;
};


export interface ICase2Query {
params: Case2Params;
result: ICase2Result;
};

10 changes: 10 additions & 0 deletions tests/demo/typescript/statement/switch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { sql } from 'sqlx-ts'


switch (true) {
case true:
const case1 = sql`SELECT id FROM items`;
break;
default:
const case2 = sql`SELECT id FROM items`;
}
42 changes: 0 additions & 42 deletions tests/demo/typescript/ts-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,9 @@ SELECT * FROM items
// expressions //
/////////////////

const query0 = sql`
SELECT id, points
FROM items;
`;

const queryCompount = sql`
SELECT items.id, tables.id
FROM items
JOIN tables ON items.table_id = tables.id;
`;

const query1 = sql`SELECT * FROM items;`;
// variable de
const query2 = sql`
SELECT * FROM items;
`;

///////////////
// functions //
///////////////
function test() {
const query3 = sql`
SELECT * FROM items;
`;

return sql`
-- @name: testQuery
INSERT INTO
items (food_type, time_takes_to_cook, table_id, points)
VALUES ('steak', 1, 1, 20);
`;
}

///////////////////
// If statements //
///////////////////
if (true) {
const query3 = sql`SELECT * FROM items;`;
}

function testIfStatement() {
if (true) {
const query3 = sql`SELECT * FROM items;`;
}
}

//////////////////////
// Switch Statement //
Expand Down

0 comments on commit 7a6008d

Please sign in to comment.