Skip to content

Commit

Permalink
refactor(inventory-entry): adjust graphql types
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosCortizasCT committed Dec 5, 2024
1 parent a821784 commit a660857
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 58 deletions.
1 change: 1 addition & 0 deletions models/inventory-entry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@commercetools-test-data/channel": "10.10.1",
"@commercetools-test-data/commons": "10.10.1",
"@commercetools-test-data/core": "10.10.1",
"@commercetools-test-data/graphql-types": "10.10.1",
"@commercetools-test-data/product": "10.10.1",
"@commercetools-test-data/utils": "10.10.1",
"@commercetools/platform-sdk": "7.14.0",
Expand Down
50 changes: 0 additions & 50 deletions models/inventory-entry/src/builders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,53 +112,3 @@ describe('InventoryEntry model compatibility builders', () => {
);
});
});

describe('builder without supply channel', () => {
it(
...createBuilderSpec<TInventoryEntry, TInventoryEntryRest>(
'rest',
InventoryEntry.random().supplyChannel(null),
expect.objectContaining({
id: expect.any(String),
key: expect.any(String),
version: expect.any(Number),
createdAt: expect.any(String),
createdBy: null,
lastModifiedAt: expect.any(String),
lastModifiedBy: null,
sku: expect.any(String),
quantityOnStock: expect.any(Number),
restockableInDays: expect.any(Number),
availableQuantity: expect.any(Number),
expectedDelivery: expect.any(String),
supplyChannel: undefined,
custom: null,
})
)
);

it(
...createBuilderSpec<TInventoryEntry, TInventoryEntryGraphql>(
'graphql',
InventoryEntry.random().supplyChannel(null),
expect.objectContaining({
id: expect.any(String),
key: expect.any(String),
version: expect.any(Number),
createdAt: expect.any(String),
createdBy: null,
lastModifiedAt: expect.any(String),
lastModifiedBy: null,
sku: expect.any(String),
quantityOnStock: expect.any(Number),
restockableInDays: expect.any(Number),
availableQuantity: expect.any(Number),
expectedDelivery: expect.any(String),
supplyChannel: null,
supplyChannelRef: undefined,
custom: null,
__typename: 'InventoryEntry',
})
)
);
});
14 changes: 6 additions & 8 deletions models/inventory-entry/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import {
InventoryEntry,
InventoryEntryDraft,
} from '@commercetools/platform-sdk';
import { TChannelGraphql } from '@commercetools-test-data/channel';
import type { TReferenceGraphql } from '@commercetools-test-data/commons';
import type { TBuilder } from '@commercetools-test-data/core';
import type {
TCtpInventoryEntry,
TCtpInventoryEntryDraft,
} from '@commercetools-test-data/graphql-types';

// Default
/**
Expand All @@ -18,12 +20,8 @@ export type TInventoryEntryRest = InventoryEntry;
export type TInventoryEntryDraftRest = InventoryEntryDraft;

// GraphQL
export type TInventoryEntryGraphql = Omit<InventoryEntry, 'supplyChannel'> & {
__typename: 'InventoryEntry';
supplyChannel?: TChannelGraphql | null;
supplyChannelRef?: TReferenceGraphql<'channel'> | null;
};
export type TInventoryEntryDraftGraphql = TInventoryEntryDraft;
export type TInventoryEntryGraphql = TCtpInventoryEntry;
export type TInventoryEntryDraftGraphql = TCtpInventoryEntryDraft;

export type TInventoryEntryBuilder = TBuilder<TInventoryEntry>;
export type TInventoryEntryDraftBuilder = TBuilder<TInventoryEntryDraft>;
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a660857

Please sign in to comment.