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
112 lines
2.6 KiB
TypeScript
112 lines
2.6 KiB
TypeScript
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)
|
|
})
|
|
})
|
|
})
|