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

feat(attribute-plain-enum-value): add attribute-plain-enum-value-draft #486

Merged
merged 3 commits into from
Feb 22, 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
5 changes: 5 additions & 0 deletions .changeset/light-moons-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-test-data/product-type': minor
---

Adds AttributePlainEnumValueDraft model.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable jest/no-disabled-tests */
/* eslint-disable jest/valid-title */
import { createBuilderSpec } from '@commercetools-test-data/core/test-utils';
import {
TAttributePlainEnumValueDraft,
TAttributePlainEnumValueDraftGraphql,
} from '../types';
import * as AttributePlainEnumValueDraft from './index';

describe('builder', () => {
it(
...createBuilderSpec<
TAttributePlainEnumValueDraft,
TAttributePlainEnumValueDraft
>(
'default',
AttributePlainEnumValueDraft.random(),
expect.objectContaining({
key: expect.any(String),
label: expect.any(String),
})
)
);

it(
...createBuilderSpec<
TAttributePlainEnumValueDraft,
TAttributePlainEnumValueDraftGraphql
>(
'graphql',
AttributePlainEnumValueDraft.random(),
expect.objectContaining({
key: expect.any(String),
label: expect.any(String),
})
)
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Builder } from '@commercetools-test-data/core';
import {
TAttributePlainEnumValueDraft,
TCreateAttributePlainEnumValueDraftBuilder,
} from '../types';
import { generator } from './generator';
import transformers from './transformers';

const Model: TCreateAttributePlainEnumValueDraftBuilder = () =>
Builder<TAttributePlainEnumValueDraft>({
generator,
transformers,
});

export default Model;
Original file line number Diff line number Diff line change
@@ -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<TAttributePlainEnumValueDraft>({
fields: {
key: fake((f) => f.lorem.slug(2)),
label: fake((f) => f.lorem.slug(2)),
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as random } from './builder';
export { default as presets } from './presets';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const presets = {};

export default presets;
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 7 additions & 0 deletions models/product-type/src/attribute-plain-enum-value/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ 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 = AttributePlainEnumValue;

export type TAttributePlainEnumValueBuilder =
TBuilder<TAttributePlainEnumValue>;
export type TCreateAttributePlainEnumValueBuilder =
() => TAttributePlainEnumValueBuilder;

export type TAttributePlainEnumValueDraftBuilder =
TBuilder<TAttributePlainEnumValueDraft>;
export type TCreateAttributePlainEnumValueDraftBuilder =
() => TAttributePlainEnumValueDraftBuilder;
Loading