-
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.
feat(test-data): create
StandalonePrice
model and associated draft (#…
…472) * chore(test-data): create standalone prices model with draft * chore(test-data): generate changeset * chore(test-data): revise package version * chore(test-data): add pricess team as codeowner * chore(test-data): remove duplicated field type * chore(test-data): test public api for model
- Loading branch information
Showing
39 changed files
with
1,809 additions
and
22 deletions.
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,7 @@ | ||
--- | ||
'@commercetools-test-data/standalone-price': minor | ||
'@commercetools-test-data/commons': minor | ||
'@commercetools-test-data/graphql-types': minor | ||
--- | ||
|
||
Create standalone prices model and associated draft, support channel key reference preset |
Validating CODEOWNERS rules …
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
10 changes: 10 additions & 0 deletions
10
models/commons/src/key-reference/presets/channel-reference.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,10 @@ | ||
import type { TKeyReference } from '../types'; | ||
import channelReference from './channel-reference'; | ||
|
||
it('should build channel reference', () => { | ||
const built = channelReference().build<TKeyReference>(); | ||
expect(built).toEqual({ | ||
key: expect.any(String), | ||
typeId: 'channel', | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
models/commons/src/key-reference/presets/channel-reference.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,6 @@ | ||
import KeyReference from '../builder'; | ||
import type { TKeyReferenceBuilder } from '../types'; | ||
|
||
const channel = (): TKeyReferenceBuilder => KeyReference().typeId('channel'); | ||
|
||
export default channel; |
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
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,57 @@ | ||
/* eslint-disable jest/no-disabled-tests */ | ||
/* eslint-disable jest/valid-title */ | ||
import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; | ||
import { TPriceTier, TPriceTierGraphql } from './types'; | ||
import * as PriceTier from '.'; | ||
|
||
describe('builder', () => { | ||
it( | ||
...createBuilderSpec<TPriceTier, TPriceTier>( | ||
'default', | ||
PriceTier.random(), | ||
expect.objectContaining({ | ||
minimumQuantity: expect.any(Number), | ||
value: expect.objectContaining({ | ||
type: 'centPrecision', | ||
currencyCode: expect.any(String), | ||
centAmount: expect.any(Number), | ||
fractionDigits: expect.any(Number), | ||
}), | ||
}) | ||
) | ||
); | ||
|
||
it( | ||
...createBuilderSpec<TPriceTier, TPriceTier>( | ||
'rest', | ||
PriceTier.random(), | ||
expect.objectContaining({ | ||
minimumQuantity: expect.any(Number), | ||
value: expect.objectContaining({ | ||
type: 'centPrecision', | ||
currencyCode: expect.any(String), | ||
centAmount: expect.any(Number), | ||
fractionDigits: expect.any(Number), | ||
}), | ||
}) | ||
) | ||
); | ||
|
||
it( | ||
...createBuilderSpec<TPriceTier, TPriceTierGraphql>( | ||
'graphql', | ||
PriceTier.random(), | ||
expect.objectContaining({ | ||
minimumQuantity: expect.any(Number), | ||
value: expect.objectContaining({ | ||
type: 'centPrecision', | ||
currencyCode: expect.any(String), | ||
centAmount: expect.any(Number), | ||
fractionDigits: expect.any(Number), | ||
__typename: 'Money', | ||
}), | ||
__typename: 'ProductPriceTier', | ||
}) | ||
) | ||
); | ||
}); |
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,12 @@ | ||
import { Builder } from '@commercetools-test-data/core'; | ||
import generator from './generator'; | ||
import transformers from './transformers'; | ||
import type { TPriceTier, TCreatePriceTierBuilder } from './types'; | ||
|
||
const Model: TCreatePriceTierBuilder = () => | ||
Builder<TPriceTier>({ | ||
generator, | ||
transformers, | ||
}); | ||
|
||
export default Model; |
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,14 @@ | ||
import { Generator, fake } from '@commercetools-test-data/core'; | ||
import * as CentPrecisionMoney from '../cent-precision-money'; | ||
import { TPriceTier } from './types'; | ||
|
||
// https://docs.commercetools.com/api/types#pricetier | ||
|
||
const generator = Generator<TPriceTier>({ | ||
fields: { | ||
minimumQuantity: fake((f) => f.number.int()), | ||
value: fake(() => CentPrecisionMoney.random()), | ||
}, | ||
}); | ||
|
||
export default generator; |
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'; |
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; |
Oops, something went wrong.