-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:plentymarkets/storefront-nuxt3-boil…
…erplate into feat/paypal-test
- Loading branch information
Showing
11 changed files
with
457 additions
and
223 deletions.
There are no files selected for viewing
This file was deleted.
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
56 changes: 56 additions & 0 deletions
56
apps/web/composables/useProductAttributes/__tests__/useProductAttributes.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,56 @@ | ||
import ProductFixture from "./../../../utils/__tests__/__fixtures__/Product"; | ||
|
||
describe('useProductAttributes', () => { | ||
it('should initialize state correctly', () => { | ||
const { attributes, attributeValues, combinations, itemId, variationId } = useProductAttributes(); | ||
|
||
expect(attributes.value).toEqual([]); | ||
expect(attributeValues.value).toEqual({}); | ||
expect(combinations.value).toEqual([]); | ||
expect(itemId.value).toBe(0); | ||
expect(variationId.value).toBe(0); | ||
}); | ||
|
||
it('should update attribute values', () => { | ||
const { setAttribute, updateValue, attributeValues } = useProductAttributes(); | ||
setAttribute(ProductFixture, true); | ||
updateValue(1, 1); | ||
|
||
expect(attributeValues.value).toEqual({ 1: 1 }); | ||
}); | ||
|
||
|
||
it('should should return empty object if value is not found during update', () => { | ||
const { setAttribute, updateValue, attributeValues } = useProductAttributes(); | ||
setAttribute(ProductFixture, true); | ||
updateValue(1, 2); | ||
|
||
expect(attributeValues.value).toEqual({}); | ||
}); | ||
|
||
it('should get the correct combination of attributes', () => { | ||
const { setAttribute, getCombination } = useProductAttributes(); | ||
|
||
setAttribute(ProductFixture, true); | ||
const combination = getCombination(); | ||
|
||
expect(combination).toEqual({ | ||
attributes: [], | ||
isSalable: true, | ||
unitCombinationId: 9, | ||
unitId: 5, | ||
unitName: "2 liter", | ||
variationId: 1100, | ||
}); | ||
}); | ||
|
||
it('should get the correct attribute value', () => { | ||
const { setAttribute, updateValue, getValue } = useProductAttributes(); | ||
setAttribute(ProductFixture, true); | ||
updateValue(1, 1); | ||
|
||
const value = getValue(1); | ||
|
||
expect(value).toBe(1); | ||
}); | ||
}); |
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
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
Oops, something went wrong.