-
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(): add StagedStandalonePrice model (#632)
- Loading branch information
Showing
8 changed files
with
120 additions
and
0 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,5 @@ | ||
--- | ||
'@commercetools-test-data/standalone-price': minor | ||
--- | ||
|
||
Added StagedStandalonePrice model within the StandalonePrice entity |
46 changes: 46 additions & 0 deletions
46
models/standalone-price/src/staged-standalone-price/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,46 @@ | ||
/* eslint-disable jest/no-disabled-tests */ | ||
/* eslint-disable jest/valid-title */ | ||
import { createBuilderSpec } from '@commercetools-test-data/core/test-utils'; | ||
import { TStagedStandalonePrice, TStagedStandalonePriceGraphql } from './types'; | ||
import * as StagedStandalonePrice from '.'; | ||
|
||
describe('builder', () => { | ||
it( | ||
...createBuilderSpec<TStagedStandalonePrice, TStagedStandalonePrice>( | ||
'default', | ||
StagedStandalonePrice.random(), | ||
expect.objectContaining({ | ||
value: expect.objectContaining({ | ||
currencyCode: expect.any(String), | ||
centAmount: expect.any(Number), | ||
}), | ||
}) | ||
) | ||
); | ||
|
||
it( | ||
...createBuilderSpec<TStagedStandalonePrice, TStagedStandalonePrice>( | ||
'rest', | ||
StagedStandalonePrice.random(), | ||
expect.objectContaining({ | ||
value: expect.objectContaining({ | ||
currencyCode: expect.any(String), | ||
centAmount: expect.any(Number), | ||
}), | ||
}) | ||
) | ||
); | ||
|
||
it( | ||
...createBuilderSpec<TStagedStandalonePrice, TStagedStandalonePriceGraphql>( | ||
'graphql', | ||
StagedStandalonePrice.random(), | ||
expect.objectContaining({ | ||
value: expect.objectContaining({ | ||
currencyCode: expect.any(String), | ||
centAmount: expect.any(Number), | ||
}), | ||
}) | ||
) | ||
); | ||
}); |
15 changes: 15 additions & 0 deletions
15
models/standalone-price/src/staged-standalone-price/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 generator from './generator'; | ||
import transformers from './transformers'; | ||
import type { | ||
TStagedStandalonePrice, | ||
TCreateStagedStandalonePriceBuilder, | ||
} from './types'; | ||
|
||
const Model: TCreateStagedStandalonePriceBuilder = () => | ||
Builder<TStagedStandalonePrice>({ | ||
generator, | ||
transformers, | ||
}); | ||
|
||
export default Model; |
14 changes: 14 additions & 0 deletions
14
models/standalone-price/src/staged-standalone-price/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,14 @@ | ||
import { Money } from '@commercetools-test-data/commons'; | ||
import { fake, Generator } from '@commercetools-test-data/core'; | ||
import { TStagedStandalonePrice } from './types'; | ||
|
||
// https://docs.commercetools.com/api/projects/standalone-prices#stagedstandaloneprice | ||
|
||
const generator = Generator<TStagedStandalonePrice>({ | ||
fields: { | ||
value: fake(() => Money.random()), | ||
discounted: null, | ||
}, | ||
}); | ||
|
||
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,2 @@ | ||
export { default as random } from './builder'; | ||
export { default as presets } from './presets'; |
3 changes: 3 additions & 0 deletions
3
models/standalone-price/src/staged-standalone-price/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; |
25 changes: 25 additions & 0 deletions
25
models/standalone-price/src/staged-standalone-price/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,25 @@ | ||
import { Transformer } from '@commercetools-test-data/core'; | ||
import type { | ||
TStagedStandalonePrice, | ||
TStagedStandalonePriceGraphql, | ||
} from './types'; | ||
|
||
const transformers = { | ||
default: Transformer<TStagedStandalonePrice, TStagedStandalonePrice>( | ||
'default', | ||
{ | ||
buildFields: ['value'], | ||
} | ||
), | ||
rest: Transformer<TStagedStandalonePrice, TStagedStandalonePrice>('rest', { | ||
buildFields: ['value'], | ||
}), | ||
graphql: Transformer<TStagedStandalonePrice, TStagedStandalonePriceGraphql>( | ||
'graphql', | ||
{ | ||
buildFields: ['value'], | ||
} | ||
), | ||
}; | ||
|
||
export default transformers; |
10 changes: 10 additions & 0 deletions
10
models/standalone-price/src/staged-standalone-price/types.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 { StagedStandalonePrice } from '@commercetools/platform-sdk'; | ||
import { TBuilder } from '@commercetools-test-data/core'; | ||
|
||
export type TStagedStandalonePrice = StagedStandalonePrice; | ||
|
||
export type TStagedStandalonePriceGraphql = TStagedStandalonePrice; | ||
|
||
export type TStagedStandalonePriceBuilder = TBuilder<TStagedStandalonePrice>; | ||
export type TCreateStagedStandalonePriceBuilder = | ||
() => TStagedStandalonePriceBuilder; |