sql-code-generator
Version:
Generate code from your SQL schema and queries for type safety and development speed.
37 lines • 2.41 kB
JavaScript
;
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 domain_1 = require("../../../../domain");
const directory_1 = require("../../../__test_assets__/directory");
const readConfig_1 = require("./readConfig");
describe('readConfig', () => {
it('should be able to read a fully declared config', () => __awaiter(void 0, void 0, void 0, function* () {
const config = yield (0, readConfig_1.readConfig)({
filePath: `${directory_1.TEST_ASSETS_ROOT_DIR}/exampleProject/mysql/codegen.sql.yml`,
});
expect(config).toBeInstanceOf(domain_1.GeneratorConfig);
expect(config.language).toEqual('mysql');
expect(config.dialect).toEqual('5.7');
expect(config.declarations.length).toEqual(12);
expect(Object.assign(Object.assign({}, config), { rootDir: '__DIR__' })).toMatchSnapshot(); // to log an example of the output; note we mask dir to make it machine independent
}));
it('should be able to read a config without queries', () => __awaiter(void 0, void 0, void 0, function* () {
const config = yield (0, readConfig_1.readConfig)({
filePath: `${directory_1.TEST_ASSETS_ROOT_DIR}/exampleProject/postgres-noqueries/codegen.sql.yml`,
});
expect(config).toBeInstanceOf(domain_1.GeneratorConfig);
expect(config.language).toEqual('postgres');
expect(config.dialect).toEqual('10.7');
expect(config.declarations.length).toEqual(3);
expect(Object.assign(Object.assign({}, config), { rootDir: '__DIR__' })).toMatchSnapshot(); // to log an example of the output; note we mask dir to make it machine independent
}));
});
//# sourceMappingURL=readConfig.integration.test.js.map