UNPKG

sql-code-generator

Version:

Generate code from your SQL schema and queries for type safety and development speed.

39 lines 2.14 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const extractSqlFromTsFile_1 = require("./extractSqlFromTsFile"); const TEST_ASSETS_DIR = `${__dirname}/__test_assets__`; describe('extractSqlFromTsFile', () => { it('should extract sql from a file that only has sql exported', () => __awaiter(void 0, void 0, void 0, function* () { const sql = yield (0, extractSqlFromTsFile_1.extractSqlFromTsFile)({ filePath: `${TEST_ASSETS_DIR}/onlyExportSql.ts`, }); expect(sql).toMatchSnapshot(); })); it('should extract sql that exports the sql and imports and exports other things', () => __awaiter(void 0, void 0, void 0, function* () { const sql = yield (0, extractSqlFromTsFile_1.extractSqlFromTsFile)({ filePath: `${TEST_ASSETS_DIR}/importAndExportThingsIncludingSql.ts`, }); expect(sql).toMatchSnapshot(); })); it('should throw standard error if sql could not be extracted', () => __awaiter(void 0, void 0, void 0, function* () { try { yield (0, extractSqlFromTsFile_1.extractSqlFromTsFile)({ filePath: `${TEST_ASSETS_DIR}/dontExportSql.ts`, }); throw new Error('should not reach here'); } catch (error) { expect(error.message).toContain('could not extract sql from file at path '); } })); }); //# sourceMappingURL=extractSqlFromTsFile.test.js.map