From 300bfe83489d5e70e12c7e63aab27af318d7e8de Mon Sep 17 00:00:00 2001 From: Tyler Ford Date: Thu, 22 Feb 2024 13:06:07 -0700 Subject: [PATCH 1/3] feat(attribute-plain-enum-value): add attribute-plain-enum-value-draft --- .../builder.spec.ts | 39 +++++++++++++++++++ .../builder.ts | 15 +++++++ .../generator.ts | 11 ++++++ .../attribute-plain-enum-value-draft/index.ts | 2 + .../presets/index.ts | 3 ++ .../transformers.ts | 22 +++++++++++ .../src/attribute-plain-enum-value/types.ts | 10 +++++ 7 files changed, 102 insertions(+) create mode 100644 models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.spec.ts create mode 100644 models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.ts create mode 100644 models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/generator.ts create mode 100644 models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/index.ts create mode 100644 models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/presets/index.ts create mode 100644 models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/transformers.ts diff --git a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.spec.ts b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.spec.ts new file mode 100644 index 000000000..eef7fc1ac --- /dev/null +++ b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.spec.ts @@ -0,0 +1,39 @@ +/* eslint-disable jest/no-disabled-tests */ +/* eslint-disable jest/valid-title */ +import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; +import { + TAttributePlainEnumValue, + TAttributePlainEnumValueDraft, + TAttributePlainEnumValueDraftGraphql, +} from '../types'; +import * as AttributePlainEnumValueDraft from './index'; + +describe('builder', () => { + it( + ...createBuilderSpec< + TAttributePlainEnumValue, + TAttributePlainEnumValueDraft + >( + 'default', + AttributePlainEnumValueDraft.random(), + expect.objectContaining({ + key: expect.any(String), + label: expect.any(String), + }) + ) + ); + + it( + ...createBuilderSpec< + TAttributePlainEnumValue, + TAttributePlainEnumValueDraftGraphql + >( + 'graphql', + AttributePlainEnumValueDraft.random(), + expect.objectContaining({ + key: expect.any(String), + label: expect.any(String), + }) + ) + ); +}); diff --git a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.ts b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.ts new file mode 100644 index 000000000..6e4422987 --- /dev/null +++ b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.ts @@ -0,0 +1,15 @@ +import { Builder } from '@commercetools-test-data/core'; +import { + TAttributePlainEnumValue, + TCreateAttributePlainEnumValueDraftBuilder, +} from '../types'; +import { generator } from './generator'; +import transformers from './transformers'; + +const Model: TCreateAttributePlainEnumValueDraftBuilder = () => + Builder({ + generator, + transformers, + }); + +export default Model; diff --git a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/generator.ts b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/generator.ts new file mode 100644 index 000000000..fb3368a80 --- /dev/null +++ b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/generator.ts @@ -0,0 +1,11 @@ +import { fake, Generator } from '@commercetools-test-data/core'; +import { TAttributePlainEnumValueDraft } from '../types'; + +// https://docs.commercetools.com/api/projects/productTypes#attributeplainenumvalue + +export const generator = Generator({ + fields: { + key: fake((f) => f.lorem.slug(2)), + label: fake((f) => f.lorem.slug(2)), + }, +}); diff --git a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/index.ts b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/index.ts new file mode 100644 index 000000000..96e2519e1 --- /dev/null +++ b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/index.ts @@ -0,0 +1,2 @@ +export { default as random } from './builder'; +export { default as presets } from './presets'; diff --git a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/presets/index.ts b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/presets/index.ts new file mode 100644 index 000000000..763e57fe0 --- /dev/null +++ b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/presets/index.ts @@ -0,0 +1,3 @@ +const presets = {}; + +export default presets; diff --git a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/transformers.ts b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/transformers.ts new file mode 100644 index 000000000..60de5a70d --- /dev/null +++ b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/transformers.ts @@ -0,0 +1,22 @@ +import { Transformer } from '@commercetools-test-data/core'; +import { + TAttributePlainEnumValueDraftGraphql, + TAttributePlainEnumValueDraft, +} from '../types'; + +const transformers = { + default: Transformer< + TAttributePlainEnumValueDraft, + TAttributePlainEnumValueDraft + >('default', { + buildFields: [], + }), + graphql: Transformer< + TAttributePlainEnumValueDraft, + TAttributePlainEnumValueDraftGraphql + >('graphql', { + buildFields: [], + }), +}; + +export default transformers; diff --git a/models/product-type/src/attribute-plain-enum-value/types.ts b/models/product-type/src/attribute-plain-enum-value/types.ts index b5a5bfb0a..bfe5c9a8f 100644 --- a/models/product-type/src/attribute-plain-enum-value/types.ts +++ b/models/product-type/src/attribute-plain-enum-value/types.ts @@ -2,12 +2,22 @@ import { AttributePlainEnumValue } from '@commercetools/platform-sdk'; import type { TBuilder } from '@commercetools-test-data/core'; export type TAttributePlainEnumValue = AttributePlainEnumValue; +export type TAttributePlainEnumValueDraft = AttributePlainEnumValue; export type TAttributePlainEnumValueGraphql = TAttributePlainEnumValue & { __typename: 'AttributePlainEnumValue'; }; +export type TAttributePlainEnumValueDraftGraphql = { + key: string; + label: string; +}; export type TAttributePlainEnumValueBuilder = TBuilder; export type TCreateAttributePlainEnumValueBuilder = () => TAttributePlainEnumValueBuilder; + +export type TAttributePlainEnumValueDraftBuilder = + TBuilder; +export type TCreateAttributePlainEnumValueDraftBuilder = + () => TAttributePlainEnumValueDraftBuilder; From d272d0ca2daf0e238dd0b5901e9a32dbe1ed4aad Mon Sep 17 00:00:00 2001 From: Tyler Ford Date: Thu, 22 Feb 2024 13:10:50 -0700 Subject: [PATCH 2/3] fix(attribute-plain-enum-value-draft): fix copy paste error and add changeset --- .changeset/light-moons-divide.md | 5 +++++ .../attribute-plain-enum-value-draft/builder.spec.ts | 5 ++--- .../attribute-plain-enum-value-draft/builder.ts | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .changeset/light-moons-divide.md diff --git a/.changeset/light-moons-divide.md b/.changeset/light-moons-divide.md new file mode 100644 index 000000000..e4504999a --- /dev/null +++ b/.changeset/light-moons-divide.md @@ -0,0 +1,5 @@ +--- +'@commercetools-test-data/product-type': minor +--- + +Adds AttributePlainEnumValueDraft model. diff --git a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.spec.ts b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.spec.ts index eef7fc1ac..8c093123c 100644 --- a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.spec.ts +++ b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.spec.ts @@ -2,7 +2,6 @@ /* eslint-disable jest/valid-title */ import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; import { - TAttributePlainEnumValue, TAttributePlainEnumValueDraft, TAttributePlainEnumValueDraftGraphql, } from '../types'; @@ -11,7 +10,7 @@ import * as AttributePlainEnumValueDraft from './index'; describe('builder', () => { it( ...createBuilderSpec< - TAttributePlainEnumValue, + TAttributePlainEnumValueDraft, TAttributePlainEnumValueDraft >( 'default', @@ -25,7 +24,7 @@ describe('builder', () => { it( ...createBuilderSpec< - TAttributePlainEnumValue, + TAttributePlainEnumValueDraft, TAttributePlainEnumValueDraftGraphql >( 'graphql', diff --git a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.ts b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.ts index 6e4422987..0c8470fd0 100644 --- a/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.ts +++ b/models/product-type/src/attribute-plain-enum-value/attribute-plain-enum-value-draft/builder.ts @@ -1,13 +1,13 @@ import { Builder } from '@commercetools-test-data/core'; import { - TAttributePlainEnumValue, + TAttributePlainEnumValueDraft, TCreateAttributePlainEnumValueDraftBuilder, } from '../types'; import { generator } from './generator'; import transformers from './transformers'; const Model: TCreateAttributePlainEnumValueDraftBuilder = () => - Builder({ + Builder({ generator, transformers, }); From f99938caade0e6cbfb0d6c262549f4d6a3733ddf Mon Sep 17 00:00:00 2001 From: Tyler Ford Date: Thu, 22 Feb 2024 13:12:41 -0700 Subject: [PATCH 3/3] fix(attribute-plain-enum-value-draft): simplify graphql type --- models/product-type/src/attribute-plain-enum-value/types.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/models/product-type/src/attribute-plain-enum-value/types.ts b/models/product-type/src/attribute-plain-enum-value/types.ts index bfe5c9a8f..f618acc31 100644 --- a/models/product-type/src/attribute-plain-enum-value/types.ts +++ b/models/product-type/src/attribute-plain-enum-value/types.ts @@ -7,10 +7,7 @@ export type TAttributePlainEnumValueDraft = AttributePlainEnumValue; export type TAttributePlainEnumValueGraphql = TAttributePlainEnumValue & { __typename: 'AttributePlainEnumValue'; }; -export type TAttributePlainEnumValueDraftGraphql = { - key: string; - label: string; -}; +export type TAttributePlainEnumValueDraftGraphql = AttributePlainEnumValue; export type TAttributePlainEnumValueBuilder = TBuilder;