-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test-data): create
AttributeNumberType
model (#485)
* chore(td): create AttributeNumberType model * chore(td): fix readme markdown
- Loading branch information
Showing
16 changed files
with
230 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@commercetools-test-data/product-type': minor | ||
--- | ||
|
||
Create AttributeNumberType product-type model and associated draft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
models/product-type/src/attribute-number-type/attribute-number-type-draft/builder.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable jest/no-disabled-tests */ | ||
/* eslint-disable jest/valid-title */ | ||
import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; | ||
import { | ||
TAttributeNumberType, | ||
TAttributeNumberTypeDraft, | ||
TAttributeNumberTypeDraftGraphql, | ||
} from '../types'; | ||
import * as AttributeNumberTypeDraft from './index'; | ||
|
||
describe('builder', () => { | ||
it( | ||
...createBuilderSpec<TAttributeNumberType, TAttributeNumberTypeDraft>( | ||
'default', | ||
AttributeNumberTypeDraft.random(), | ||
expect.objectContaining({ | ||
name: 'number', | ||
}) | ||
) | ||
); | ||
|
||
it( | ||
...createBuilderSpec< | ||
TAttributeNumberType, | ||
TAttributeNumberTypeDraftGraphql | ||
>( | ||
'graphql', | ||
AttributeNumberTypeDraft.random(), | ||
expect.objectContaining({ | ||
number: { | ||
dummy: null, | ||
}, | ||
}) | ||
) | ||
); | ||
}); |
15 changes: 15 additions & 0 deletions
15
models/product-type/src/attribute-number-type/attribute-number-type-draft/builder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Builder } from '@commercetools-test-data/core'; | ||
import { | ||
TAttributeNumberType, | ||
TCreateAttributeNumberTypeDraftBuilder, | ||
} from '../types'; | ||
import { generator } from './generator'; | ||
import transformers from './transformers'; | ||
|
||
const Model: TCreateAttributeNumberTypeDraftBuilder = () => | ||
Builder<TAttributeNumberType>({ | ||
generator, | ||
transformers, | ||
}); | ||
|
||
export default Model; |
10 changes: 10 additions & 0 deletions
10
models/product-type/src/attribute-number-type/attribute-number-type-draft/generator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Generator } from '@commercetools-test-data/core'; | ||
import { TAttributeNumberTypeDraft } from '../types'; | ||
|
||
// https://docs.commercetools.com/api/projects/productTypes#attributeenumtype | ||
|
||
export const generator = Generator<TAttributeNumberTypeDraft>({ | ||
fields: { | ||
name: 'number', | ||
}, | ||
}); |
2 changes: 2 additions & 0 deletions
2
models/product-type/src/attribute-number-type/attribute-number-type-draft/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
3 changes: 3 additions & 0 deletions
3
models/product-type/src/attribute-number-type/attribute-number-type-draft/presets/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const presets = {}; | ||
|
||
export default presets; |
27 changes: 27 additions & 0 deletions
27
models/product-type/src/attribute-number-type/attribute-number-type-draft/transformers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Transformer } from '@commercetools-test-data/core'; | ||
import { | ||
TAttributeNumberTypeDraftGraphql, | ||
TAttributeNumberTypeDraft, | ||
} from '../types'; | ||
|
||
const transformers = { | ||
default: Transformer<TAttributeNumberTypeDraft, TAttributeNumberTypeDraft>( | ||
'default', | ||
{ | ||
buildFields: [], | ||
} | ||
), | ||
graphql: Transformer< | ||
TAttributeNumberTypeDraft, | ||
TAttributeNumberTypeDraftGraphql | ||
>('graphql', { | ||
buildFields: [], | ||
replaceFields: () => ({ | ||
number: { | ||
dummy: null, | ||
}, | ||
}), | ||
}), | ||
}; | ||
|
||
export default transformers; |
38 changes: 38 additions & 0 deletions
38
models/product-type/src/attribute-number-type/builder.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { TAttributeNumberType, TAttributeNumberTypeGraphql } from './types'; | ||
import * as AttributeEnumType from './index'; | ||
|
||
describe('builder', () => { | ||
it( | ||
...createBuilderSpec<TAttributeNumberType, TAttributeNumberType>( | ||
'default', | ||
AttributeEnumType.random(), | ||
expect.objectContaining({ | ||
name: 'number', | ||
}) | ||
) | ||
); | ||
|
||
it( | ||
...createBuilderSpec<TAttributeNumberType, TAttributeNumberType>( | ||
'rest', | ||
AttributeEnumType.random(), | ||
expect.objectContaining({ | ||
name: 'number', | ||
}) | ||
) | ||
); | ||
|
||
it( | ||
...createBuilderSpec<TAttributeNumberType, TAttributeNumberTypeGraphql>( | ||
'graphql', | ||
AttributeEnumType.random(), | ||
expect.objectContaining({ | ||
name: 'number', | ||
__typename: 'NumberAttributeDefinitionType', | ||
}) | ||
) | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Builder } from '@commercetools-test-data/core'; | ||
import { generator } from './generator'; | ||
import transformers from './transformers'; | ||
import { | ||
TAttributeNumberType, | ||
TCreateAttributeNumberTypeBuilder, | ||
} from './types'; | ||
|
||
const Model: TCreateAttributeNumberTypeBuilder = () => | ||
Builder<TAttributeNumberType>({ | ||
generator, | ||
transformers, | ||
}); | ||
|
||
export default Model; |
10 changes: 10 additions & 0 deletions
10
models/product-type/src/attribute-number-type/generator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Generator } from '@commercetools-test-data/core'; | ||
import { TAttributeNumberType } from './types'; | ||
|
||
// https://docs.commercetools.com/api/projects/productTypes#attributenumbertype | ||
|
||
export const generator = Generator<TAttributeNumberType>({ | ||
fields: { | ||
name: 'number', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as random } from './builder'; | ||
export { default as presets } from './presets'; | ||
export * from './types'; |
3 changes: 3 additions & 0 deletions
3
models/product-type/src/attribute-number-type/presets/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const presets = {}; | ||
|
||
export default presets; |
22 changes: 22 additions & 0 deletions
22
models/product-type/src/attribute-number-type/transformers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Transformer } from '@commercetools-test-data/core'; | ||
import { TAttributeNumberTypeGraphql, TAttributeNumberType } from './types'; | ||
|
||
const transformers = { | ||
default: Transformer<TAttributeNumberType, TAttributeNumberType>('default', { | ||
buildFields: [], | ||
}), | ||
rest: Transformer<TAttributeNumberType, TAttributeNumberType>('rest', { | ||
buildFields: [], | ||
}), | ||
graphql: Transformer<TAttributeNumberType, TAttributeNumberTypeGraphql>( | ||
'graphql', | ||
{ | ||
buildFields: [], | ||
addFields: () => ({ | ||
__typename: 'NumberAttributeDefinitionType', | ||
}), | ||
} | ||
), | ||
}; | ||
|
||
export default transformers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { AttributeNumberType } from '@commercetools/platform-sdk'; | ||
import type { TBuilder } from '@commercetools-test-data/core'; | ||
|
||
export type TAttributeNumberType = AttributeNumberType; | ||
export type TAttributeNumberTypeDraft = AttributeNumberType; | ||
|
||
export type TAttributeNumberTypeGraphql = AttributeNumberType & { | ||
__typename: 'NumberAttributeDefinitionType'; | ||
}; | ||
export type TAttributeNumberTypeDraftGraphql = { | ||
number: { | ||
dummy: string | null; | ||
}; | ||
}; | ||
|
||
export type TAttributeNumberTypeBuilder = TBuilder<TAttributeNumberType>; | ||
export type TAttributeNumberTypeDraftBuilder = | ||
TBuilder<TAttributeNumberTypeDraft>; | ||
|
||
export type TCreateAttributeNumberTypeBuilder = | ||
() => TAttributeNumberTypeBuilder; | ||
export type TCreateAttributeNumberTypeDraftBuilder = | ||
() => TAttributeNumberTypeDraftBuilder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters