Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
magrinj committed Mar 12, 2024
1 parent 2faceb3 commit 42c2cf9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ describe('WorkspaceFieldComparator', () => {
it('should generate CREATE action for new fields', () => {
const original = { fields: [] } as any;
const standard = {
fields: [createMockFieldMetadata({ name: 'New Field' })],
fields: [
createMockFieldMetadata({
standardId: 'no-field-1',
name: 'New Field',
}),
],
} as any;

const result = comparator.compare(original, standard);
Expand All @@ -46,6 +51,7 @@ describe('WorkspaceFieldComparator', () => {
const original = {
fields: [
createMockFieldMetadata({
standardId: '1',
id: '1',
isNullable: true,
}),
Expand All @@ -54,6 +60,7 @@ describe('WorkspaceFieldComparator', () => {
const standard = {
fields: [
createMockFieldMetadata({
standardId: '1',
isNullable: false,
}),
],
Expand All @@ -73,6 +80,7 @@ describe('WorkspaceFieldComparator', () => {
const original = {
fields: [
createMockFieldMetadata({
standardId: '1',
id: '1',
name: 'Removed Field',
isActive: true,
Expand All @@ -93,10 +101,12 @@ describe('WorkspaceFieldComparator', () => {

it('should not generate any action for identical fields', () => {
const original = {
fields: [createMockFieldMetadata({ id: '1', isActive: true })],
fields: [
createMockFieldMetadata({ standardId: '1', id: '1', isActive: true }),
],
} as any;
const standard = {
fields: [createMockFieldMetadata({})],
fields: [createMockFieldMetadata({ standardId: '1' })],
} as any;

const result = comparator.compare(original, standard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('WorkspaceObjectComparator', () => {

it('should generate CREATE action for new objects', () => {
const standardObjectMetadata = createMockObjectMetadata({
standardId: 'no-object-1',
description: 'A standard object',
});

Expand All @@ -35,10 +36,12 @@ describe('WorkspaceObjectComparator', () => {

it('should generate UPDATE action for objects with differences', () => {
const originalObjectMetadata = createMockObjectMetadata({
standardId: '1',
id: '1',
description: 'Original description',
});
const standardObjectMetadata = createMockObjectMetadata({
standardId: '1',
description: 'Updated description',
});

Expand All @@ -58,10 +61,12 @@ describe('WorkspaceObjectComparator', () => {

it('should generate SKIP action for identical objects', () => {
const originalObjectMetadata = createMockObjectMetadata({
standardId: '1',
id: '1',
description: 'Same description',
});
const standardObjectMetadata = createMockObjectMetadata({
standardId: '1',
description: 'Same description',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ describe('mapObjectMetadataByUniqueIdentifier', () => {
it('should convert an array of ObjectMetadataEntity objects into a map', () => {
const arr: DeepPartial<ObjectMetadataEntity>[] = [
{
standardId: 'user',
nameSingular: 'user',
fields: [
{ name: 'id', type: FieldMetadataType.UUID },
{ name: 'name', type: FieldMetadataType.TEXT },
],
},
{
standardId: 'product',
nameSingular: 'product',
fields: [
{ name: 'id', type: FieldMetadataType.UUID },
Expand All @@ -29,13 +31,15 @@ describe('mapObjectMetadataByUniqueIdentifier', () => {

expect(mappedObject).toEqual({
user: {
standardId: 'user',
nameSingular: 'user',
fields: [
{ name: 'id', type: FieldMetadataType.UUID },
{ name: 'name', type: FieldMetadataType.TEXT },
],
},
product: {
standardId: 'product',
nameSingular: 'product',
fields: [
{ name: 'id', type: FieldMetadataType.UUID },
Expand Down

0 comments on commit 42c2cf9

Please sign in to comment.