UNPKG

sql-code-generator

Version:

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

48 lines 2.69 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 getAllPathsMatchingGlobs_1 = require("./getAllPathsMatchingGlobs"); const root = `${__dirname}/../../../__test_assets__/exampleProject/mysql`; // i.e., starting from the "codegen.sql.yml" describe('getAllPathsMatchingGlobs', () => { it('should return paths that match a glob', () => __awaiter(void 0, void 0, void 0, function* () { const files = yield (0, getAllPathsMatchingGlobs_1.getAllPathsMatchingGlobs)({ globs: ['schema/**/*.sql'], root, }); expect(files).toContain('schema/tables/image.sql'); expect(files).toContain('schema/functions/upsert_image.sql'); })); it('should return paths that match each glob', () => __awaiter(void 0, void 0, void 0, function* () { const files = yield (0, getAllPathsMatchingGlobs_1.getAllPathsMatchingGlobs)({ globs: ['schema/**/*.sql', 'src/dao/**/*.ts'], root, }); expect(files).toContain('schema/tables/image.sql'); expect(files).toContain('src/dao/user/findAllByName.ts'); expect(files).toContain('src/dao/user/findAllByName.test.ts'); })); it('should not return paths that match a glob that starts with "!"', () => __awaiter(void 0, void 0, void 0, function* () { const files = yield (0, getAllPathsMatchingGlobs_1.getAllPathsMatchingGlobs)({ globs: [ 'schema/**/*.sql', 'src/dao/**/*.ts', '!src/dao/**/*.test.ts', '!src/dao/**/*.test.integration.ts', ], root, }); expect(files).toContain('schema/tables/image.sql'); expect(files).toContain('src/dao/user/findAllByName.ts'); expect(files).not.toContain('src/dao/user/findAllByName.test.ts'); expect(files).not.toContain('src/dao/user/findAllByName.test.integration.ts'); })); }); //# sourceMappingURL=getAllPathsMatchingGlobs.test.js.map