feat(utils,types): added item/shipping adjustments for order/items/shipping_methods (#6050)
what: - adds compute actions for the following cases: - items => each & across - shipping_method => each & across - order - adds a remove compute actions when code is no longer present in adjustments array RESOLVES CORE-1625 RESOLVES CORE-1626 RESOLVES CORE-1627 RESOLVES CORE-1628 RESOLVES CORE-1585
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
import { pickValueFromObject } from "../pick-value-from-object"
|
||||
|
||||
describe("pickValueFromObject", function () {
|
||||
it("should return true or false for different types of data", function () {
|
||||
const expectations = [
|
||||
{
|
||||
input: {
|
||||
1: "attribute.another_attribute",
|
||||
2: {
|
||||
attribute: {
|
||||
another_attribute: "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
output: "test",
|
||||
},
|
||||
{
|
||||
input: {
|
||||
1: "attribute.another_attribute.array_attribute",
|
||||
2: {
|
||||
attribute: {
|
||||
another_attribute: [
|
||||
{
|
||||
array_attribute: "test 1",
|
||||
},
|
||||
{
|
||||
array_attribute: "test 2",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
output: ["test 1", "test 2"],
|
||||
},
|
||||
{
|
||||
input: {
|
||||
1: "attribute.another_attribute.array_attribute.deep_array_attribute",
|
||||
2: {
|
||||
attribute: {
|
||||
another_attribute: [
|
||||
{
|
||||
array_attribute: [
|
||||
{
|
||||
deep_array_attribute: "test 1",
|
||||
},
|
||||
{
|
||||
deep_array_attribute: "test 2",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
array_attribute: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
output: ["test 1", "test 2"],
|
||||
},
|
||||
{
|
||||
input: {
|
||||
1: "attribute.another_attribute.array_attribute",
|
||||
2: {
|
||||
attribute: {
|
||||
another_attribute: [
|
||||
{
|
||||
array_attribute: [
|
||||
{
|
||||
deep_array_attribute: "test 1",
|
||||
},
|
||||
{
|
||||
deep_array_attribute: "test 2",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
array_attribute: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
output: [
|
||||
{
|
||||
deep_array_attribute: "test 1",
|
||||
},
|
||||
{
|
||||
deep_array_attribute: "test 2",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
input: {
|
||||
1: "attribute.missing_attribute",
|
||||
2: {
|
||||
attribute: {
|
||||
another_attribute: "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
output: undefined,
|
||||
},
|
||||
]
|
||||
|
||||
expectations.forEach((expectation) => {
|
||||
expect(
|
||||
pickValueFromObject(expectation.input["1"], expectation.input["2"])
|
||||
).toEqual(expectation.output)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user