drawdb/test/oracle_unique.test.js
lethalSopaper d95b86b7b5
Pull-request para export a Oracle (#4)
* Permito deployment en un subfolder

* Remove vercel/analytics

* Remove vercel/analytics

* Remove vercel/analytics

* Revert "Permito deployment en un subfolder"

This reverts commit e7aedc3ecf.

* Boton de oracle funciona pero no add table

* datatypes.js fixed

* export oracle funciona, falta formato adecuado

* Agregando convenciones a constraints

* Cambiando detalle de unique constraint

* Adding a test for diagram exports to oracle

* tests for constraints added

* Correccion de la funcion check

* vercel added and tests run with npm run lint

* little fixes, vercel added in datatypes and main.jsx

* Delete tatus file added by mistake

---------

Co-authored-by: Francisco-Galindo <paqui10718@gmail.com>
Co-authored-by: hansmarcus <hansmarcus14@gmail.com>
Co-authored-by: Pablo Estrada <pabloem@apache.org>
2025-02-06 23:41:42 -05:00

46 lines
1.1 KiB
JavaScript

/* eslint-env jest */
import { toOracle } from "../src/utils/exportSQL/oracle.js";
import { DB } from "../src/data/constants.js";
describe("toOracle", () => {
test("test for unique constraints", () => {
const diagram = {
database: DB.ORACLE,
tables: [
{
name: "computador",
fields: [
{
name: "computador_id",
type: "NUMBER",
size: "10,0",
notNull: true,
primary: true,
default: "",
},
{
name: "num_serie",
type: "VARCHAR2",
size: 40,
notNull: true,
unique: true,
default: "",
},
],
indices: [],
},
],
references: [],
};
const expectedSQL = `CREATE TABLE computador (
\t"computador_id" NUMBER(10,0) NOT NULL,
\t"num_serie" VARCHAR2(40) NOT NULL,
\tCONSTRAINT computador_num_serie_uk UNIQUE("num_serie"),
\tCONSTRAINT computador_pk PRIMARY KEY("computador_id")
);`;
const result = toOracle(diagram);
expect(result.trim()).toBe(expectedSQL.trim());
});
});