-
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(presets): added presets to several entity drafts for use by audi… (
#452) * feat(presets): added presets to several entity drafts for use by audit log * feat(presets): add shopping list package to changeset * feat(presets): add shopping list presets to export
- Loading branch information
Showing
22 changed files
with
161 additions
and
4 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,9 @@ | ||
--- | ||
'@commercetools-test-data/inventory-entry': minor | ||
'@commercetools-test-data/shopping-list': minor | ||
'@commercetools-test-data/product-type': minor | ||
'@commercetools-test-data/category': minor | ||
'@commercetools-test-data/customer': minor | ||
--- | ||
|
||
Add presets to several entities for use by audit log |
7 changes: 7 additions & 0 deletions
7
models/category/src/category-draft/presets/change-history-data/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,7 @@ | ||
import withNoParent from './with-no-parent'; | ||
|
||
const presets = { | ||
withNoParent, | ||
}; | ||
|
||
export default presets; |
14 changes: 14 additions & 0 deletions
14
models/category/src/category-draft/presets/change-history-data/with-no-parent.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,14 @@ | ||
import type { TCategoryDraft } from '../../../types'; | ||
import withNoParent from './with-no-parent'; | ||
|
||
describe('Category with no parent', () => { | ||
it('should return a category containing no parent value', () => { | ||
const category = withNoParent().build<TCategoryDraft>(); | ||
|
||
expect(category).toEqual( | ||
expect.objectContaining({ | ||
parent: undefined, | ||
}) | ||
); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
models/category/src/category-draft/presets/change-history-data/with-no-parent.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,5 @@ | ||
import CategoryDraft from '../../builder'; | ||
|
||
const withCategoryNoParent = () => CategoryDraft().parent(undefined); | ||
|
||
export default withCategoryNoParent; |
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import changeHistoryData from './change-history-data'; | ||
import empty from './empty'; | ||
import sampleDataFashion from './sample-data-fashion'; | ||
import sampleDataGoodStore from './sample-data-goodstore'; | ||
|
||
const presets = { empty, sampleDataFashion, sampleDataGoodStore }; | ||
const presets = { | ||
empty, | ||
sampleDataFashion, | ||
sampleDataGoodStore, | ||
changeHistoryData, | ||
}; | ||
|
||
export default presets; |
2 changes: 2 additions & 0 deletions
2
models/customer/src/customer-draft/presets/change-history-data/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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import usBasedNoState from './us-based-with-no-state'; | ||
import withNoDob from './with-no-dob'; | ||
|
||
const presets = { | ||
usBasedNoState, | ||
withNoDob, | ||
}; | ||
|
||
export default presets; |
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
15 changes: 15 additions & 0 deletions
15
models/customer/src/customer-draft/presets/change-history-data/with-no-dob.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,15 @@ | ||
import { TCustomerDraft } from '../../../types'; | ||
import withNoDob from './with-no-dob'; | ||
|
||
describe('A customer with no date of birth', () => { | ||
it('should return customer with date of birth undefined and authentication mode set to `Password`', () => { | ||
const customer = withNoDob().build<TCustomerDraft>(); | ||
|
||
expect(customer).toEqual( | ||
expect.objectContaining({ | ||
dateOfBirth: undefined, | ||
authenticationMode: 'Password', | ||
}) | ||
); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
models/customer/src/customer-draft/presets/change-history-data/with-no-dob.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 type { TCustomerDraftBuilder } from '../../../types'; | ||
import * as CustomerDraft from '../../index'; | ||
|
||
const withNoDob = (): TCustomerDraftBuilder => | ||
CustomerDraft.random().dateOfBirth(undefined).authenticationMode('Password'); | ||
export default withNoDob; |
7 changes: 7 additions & 0 deletions
7
models/inventory-entry/src/inventory-entry-draft/presets/change-history-data/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,7 @@ | ||
import withNoSupplyChannel from './with-no-supply-channel'; | ||
|
||
const presets = { | ||
withNoSupplyChannel, | ||
}; | ||
|
||
export default presets; |
14 changes: 14 additions & 0 deletions
14
...ntry/src/inventory-entry-draft/presets/change-history-data/with-no-supply-channel.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,14 @@ | ||
import type { TInventoryEntryDraft } from '../../../types'; | ||
import withNoSupplyChannel from './with-no-supply-channel'; | ||
|
||
describe('Inventory Entry with no supply channel', () => { | ||
it('should return an inventory entry with supply channel undefined', () => { | ||
const inventoryEntry = withNoSupplyChannel().build<TInventoryEntryDraft>(); | ||
|
||
expect(inventoryEntry).toEqual( | ||
expect.objectContaining({ | ||
supplyChannel: undefined, | ||
}) | ||
); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
...ory-entry/src/inventory-entry-draft/presets/change-history-data/with-no-supply-channel.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 InventoryEntryDraft from '../../builder'; | ||
|
||
const withNoSupplyChannel = () => | ||
InventoryEntryDraft().supplyChannel(undefined); | ||
|
||
export default withNoSupplyChannel; |
2 changes: 2 additions & 0 deletions
2
models/inventory-entry/src/inventory-entry-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
7 changes: 7 additions & 0 deletions
7
models/product-type/src/product-type/product-type-draft/presets/change-history-data/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,7 @@ | ||
import withNoAttributes from './with-no-attributes'; | ||
|
||
const presets = { | ||
withNoAttributes, | ||
}; | ||
|
||
export default presets; |
14 changes: 14 additions & 0 deletions
14
...rc/product-type/product-type-draft/presets/change-history-data/with-no-attributes.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,14 @@ | ||
import type { TProductTypeDraft } from '../../../types'; | ||
import withNoAttributes from './with-no-attributes'; | ||
|
||
describe('Product type with no attributes', () => { | ||
it('should return a product type with attributes undefined', () => { | ||
const category = withNoAttributes().build<TProductTypeDraft>(); | ||
|
||
expect(category).toEqual( | ||
expect.objectContaining({ | ||
attributes: undefined, | ||
}) | ||
); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
...ype/src/product-type/product-type-draft/presets/change-history-data/with-no-attributes.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,5 @@ | ||
import ProductTypeDraft from '../../builder'; | ||
|
||
const withNoAttributes = () => ProductTypeDraft().attributes(undefined); | ||
|
||
export default withNoAttributes; |
8 changes: 7 additions & 1 deletion
8
models/product-type/src/product-type/product-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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import changeHistoryData from './change-history-data'; | ||
import empty from './empty'; | ||
import sampleDataFashion from './sample-data-fashion'; | ||
import sampleDataGoodStore from './sample-data-goodstore'; | ||
|
||
const presets = { empty, sampleDataFashion, sampleDataGoodStore }; | ||
const presets = { | ||
changeHistoryData, | ||
empty, | ||
sampleDataFashion, | ||
sampleDataGoodStore, | ||
}; | ||
|
||
export default presets; |
7 changes: 7 additions & 0 deletions
7
models/shopping-list/src/shopping-list-draft/presets/change-history-data/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,7 @@ | ||
import withNoCustomer from './with-no-customer'; | ||
|
||
const presets = { | ||
withNoCustomer, | ||
}; | ||
|
||
export default presets; |
14 changes: 14 additions & 0 deletions
14
...hopping-list/src/shopping-list-draft/presets/change-history-data/with-no-customer.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,14 @@ | ||
import type { TShoppingListDraft } from '../../../types'; | ||
import withNoCustomer from './with-no-customer'; | ||
|
||
describe('Shopping List with no customer', () => { | ||
it('should return a shopping list with customer undefined', () => { | ||
const shoppingList = withNoCustomer().build<TShoppingListDraft>(); | ||
|
||
expect(shoppingList).toEqual( | ||
expect.objectContaining({ | ||
customer: undefined, | ||
}) | ||
); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
models/shopping-list/src/shopping-list-draft/presets/change-history-data/with-no-customer.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,5 @@ | ||
import ShoppingListDraft from '../../builder'; | ||
|
||
const withNoCustomer = () => ShoppingListDraft().customer(undefined); | ||
|
||
export default withNoCustomer; |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
const presets = {}; | ||
import changeHistoryData from './change-history-data'; | ||
|
||
const presets = { | ||
changeHistoryData, | ||
}; | ||
|
||
export default presets; |