Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update field types and table width #136

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/core/model/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
export type FieldType = 'number' | 'string' | 'object' | 'objectId';
export type FieldType =
| 'any'
| 'array'
| 'binData'
| 'bool'
| 'date'
| 'dbPointer'
| 'decimal'
| 'double'
| 'enum'
| 'int'
| 'javascript'
| 'long'
| 'maxKey'
| 'minKey'
| 'null'
| 'object'
| 'objectId'
| 'regex'
| 'string'
| 'symbol'
| 'timestamp'
| 'undefined';

export type ExportType = 'svg' | 'png' | 'mongo';

export interface Size {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('calculateRelationXCoordinateOrigin', () => {
},
],
tableName: 'table1',
x: TABLE_CONST.DEFAULT_TABLE_WIDTH - 200,
x: 0,
y: 0,
};
const tableDestination: TableVm = {
Expand All @@ -46,7 +46,7 @@ describe('calculateRelationXCoordinateOrigin', () => {
},
],
tableName: 'table2',
x: TABLE_CONST.DEFAULT_TABLE_WIDTH + 200,
x: 200,
y: 0,
};

Expand All @@ -57,7 +57,7 @@ describe('calculateRelationXCoordinateOrigin', () => {
);

// Assert
expect(result).toBe(TABLE_CONST.DEFAULT_TABLE_WIDTH + 100);
expect(result).toBe(TABLE_CONST.DEFAULT_TABLE_WIDTH);
});
it('Should returns xCoordinateOrigin, if tableOrigin.x > tableDestination.x', () => {
//Arrange
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('calculateRelationXCoordinateEnd', () => {
},
],
tableName: 'table1',
x: TABLE_CONST.DEFAULT_TABLE_WIDTH + 200,
x: 200,
y: 0,
};
const tableDestination: TableVm = {
Expand All @@ -153,7 +153,7 @@ describe('calculateRelationXCoordinateEnd', () => {
},
],
tableName: 'table2',
x: TABLE_CONST.DEFAULT_TABLE_WIDTH - 200,
x: 190,
y: 0,
};

Expand All @@ -164,7 +164,8 @@ describe('calculateRelationXCoordinateEnd', () => {
);

// Assert
expect(result).toBe(TABLE_CONST.DEFAULT_TABLE_WIDTH + 100);
// TODO: REFACTOR THIS TEST IF TABLE WIDTH CHANGE THIS IS NOT VALID
expect(result).toBe(190 + TABLE_CONST.DEFAULT_TABLE_WIDTH);
});
it('Should returns xCoordinateEnd, if tableDestination.x > tableOrigin.x', () => {
//Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('findField', () => {
{
id: '1',
name: 'Hi',
type: 'number',
type: 'int',
PK: false,
},
{
Expand All @@ -32,7 +32,7 @@ describe('findField', () => {
{
id: '1',
name: 'Hi',
type: 'number',
type: 'int',
PK: false,
},
{
Expand All @@ -50,7 +50,7 @@ describe('findField', () => {
const expected: FieldVm = {
id: '1',
name: 'Hi',
type: 'number',
type: 'int',
PK: false,
};

Expand All @@ -63,7 +63,7 @@ describe('findField', () => {
{
id: '1',
name: 'Hi',
type: 'number',
type: 'int',
PK: false,
},
{
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('findField', () => {
{
id: '1',
name: 'Hi',
type: 'number',
type: 'int',
PK: false,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,13 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '4',
name: 'childField1',
type: 'number',
type: 'int',
PK: false,
},
{
id: '5',
name: 'childField2',
type: 'number',
type: 'int',
PK: false,
},
{
Expand All @@ -300,13 +300,13 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '7',
name: 'subField1',
type: 'number',
type: 'int',
PK: false,
},
{
id: '8',
name: 'subField2',
type: 'number',
type: 'int',
PK: false,
},
],
Expand Down Expand Up @@ -367,7 +367,7 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '4',
name: 'childField1',
type: 'number',
type: 'int',
PK: false,
},
{
Expand All @@ -380,13 +380,13 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '7',
name: 'subField1',
type: 'number',
type: 'int',
PK: false,
},
{
id: '8',
name: 'subField2',
type: 'number',
type: 'int',
PK: false,
},
],
Expand All @@ -401,13 +401,13 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '9',
name: 'subField1',
type: 'number',
type: 'int',
PK: false,
},
{
id: '10',
name: 'subField2',
type: 'number',
type: 'int',
PK: false,
},
],
Expand Down Expand Up @@ -468,7 +468,7 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '4',
name: 'childField1',
type: 'number',
type: 'int',
PK: false,
},
{
Expand All @@ -481,13 +481,13 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '7',
name: 'subField1',
type: 'number',
type: 'int',
PK: false,
},
{
id: '8',
name: 'subField2',
type: 'number',
type: 'int',
PK: false,
},
],
Expand All @@ -502,13 +502,13 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '9',
name: 'subField1',
type: 'number',
type: 'int',
PK: false,
},
{
id: '10',
name: 'subField2',
type: 'number',
type: 'int',
PK: false,
},
],
Expand Down Expand Up @@ -570,7 +570,7 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '4',
name: 'childField1',
type: 'number',
type: 'int',
PK: false,
},
{
Expand All @@ -583,13 +583,13 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '7',
name: 'subField1',
type: 'number',
type: 'int',
PK: false,
},
{
id: '8',
name: 'subField2',
type: 'number',
type: 'int',
PK: false,
},
],
Expand All @@ -604,13 +604,13 @@ describe('canvas.business.calculateRelationYOffset', () => {
{
id: '9',
name: 'subField1',
type: 'number',
type: 'int',
PK: false,
},
{
id: '10',
name: 'subField2',
type: 'number',
type: 'int',
PK: false,
},
],
Expand Down
12 changes: 6 additions & 6 deletions src/core/providers/canvas-schema/canvas-schema.business.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('canvas-schema.business', () => {
id: '2',
name: 'test update id name 2',
PK: false,
type: 'number',
type: 'int',
},
],
tableName: 'test update table name',
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('canvas-schema.business', () => {
id: '2',
name: 'test update id name 2',
PK: false,
type: 'number',
type: 'int',
},
],
tableName: 'test update table name',
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('canvas-schema.business', () => {
id: '2',
name: 'test update id name 2',
PK: false,
type: 'number',
type: 'int',
},
],
tableName: 'test update table name',
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('canvas-schema.business', () => {
id: '2',
name: 'test update id name 2',
PK: false,
type: 'number',
type: 'int',
},
],
tableName: 'test update table name',
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('canvas-schema.business', () => {
id: '2',
name: 'test update id name 2',
PK: false,
type: 'number',
type: 'int',
},
],
tableName: 'test update table name',
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('canvas-schema.business', () => {
id: '2',
name: 'test update id name 2',
PK: false,
type: 'number',
type: 'int',
},
],
tableName: 'test update table name',
Expand Down
Loading
Loading