Skip to content

Commit 51acee5

Browse files
IbidapoIbidapomarkus-azer
authored
feat: add localizedName action to shipping methods (#1843)
* feat: add localizedName action to shipping methods * test: add test to shipping methods * fix: ignores only malformed_package_json files --------- Co-authored-by: Ibidapo <dapsinsed@gmail.comn> Co-authored-by: Markus <markus.gihady@commercetools.com>
1 parent 0a3d4bb commit 51acee5

4 files changed

Lines changed: 50 additions & 30 deletions

File tree

.flowconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
.*/node_modules/webpack.*
5050
.*/node_modules/worker-farm/.*
5151
.*/node_modules/yargs.*
52+
.*/node_modules/.*/malformed_package_json/package.json
5253

5354
[include]
5455
packages/*/src

packages/sync-actions/src/shipping-methods-actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { buildBaseAttributesActions } from './utils/common-actions'
99
export const baseActionsList = [
1010
{ action: 'setKey', key: 'key' },
1111
{ action: 'changeName', key: 'name' },
12+
{ action: 'setLocalizedName', key: 'localizedName' },
1213
{ action: 'setDescription', key: 'description' },
1314
{ action: 'setLocalizedDescription', key: 'localizedDescription' },
1415
{ action: 'changeIsDefault', key: 'isDefault' },

packages/sync-actions/test/shipping-methods.spec.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe('Exports', () => {
1010
expect(baseActionsList).toEqual([
1111
{ action: 'setKey', key: 'key' },
1212
{ action: 'changeName', key: 'name' },
13+
{ action: 'setLocalizedName', key: 'localizedName' },
1314
{ action: 'setDescription', key: 'description' },
1415
{ action: 'setLocalizedDescription', key: 'localizedDescription' },
1516
{ action: 'changeIsDefault', key: 'isDefault' },
@@ -38,6 +39,7 @@ describe('Actions', () => {
3839
const expected = [{ action: 'setKey', key: now.key }]
3940
expect(actual).toEqual(expected)
4041
})
42+
4143
test('should build `changeName` action', () => {
4244
const before = {
4345
name: 'Shipping Method 1',
@@ -56,6 +58,49 @@ describe('Actions', () => {
5658
expect(actual).toEqual(expected)
5759
})
5860

61+
test('should build `setLocalizedName` action', () => {
62+
const before = {
63+
localizedName: {
64+
en: 'Shipping Method 1',
65+
},
66+
}
67+
const now = {
68+
localizedName: {
69+
fr: 'Méthode de expédition 1',
70+
en: 'Shipping Method 1',
71+
},
72+
}
73+
74+
const actual = shippingMethodsSync.buildActions(now, before)
75+
const expected = [
76+
{
77+
action: 'setLocalizedName',
78+
localizedName: now.localizedName,
79+
},
80+
]
81+
expect(actual).toEqual(expected)
82+
})
83+
84+
test('should build `setLocalizedName` action with an empty localizedName', () => {
85+
const before = {
86+
localizedName: {
87+
en: 'Shipping Method 1',
88+
},
89+
}
90+
const now = {
91+
localizedName: undefined,
92+
}
93+
94+
const actual = shippingMethodsSync.buildActions(now, before)
95+
const expected = [
96+
{
97+
action: 'setLocalizedName',
98+
localizedName: now.localizedName,
99+
},
100+
]
101+
expect(actual).toEqual(expected)
102+
})
103+
59104
test('should build `setDescription` action', () => {
60105
const before = {
61106
description: 'Custom description',

yarn.lock

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5571,7 +5571,7 @@ debug@^3.0.1, debug@^3.1.0, debug@^3.2.7:
55715571
dependencies:
55725572
ms "^2.1.1"
55735573

5574-
debuglog@*, debuglog@^1.0.1:
5574+
debuglog@^1.0.1:
55755575
version "1.0.1"
55765576
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
55775577
integrity sha512-syBZ+rnAK3EgMsH2aYEOLUW7mZSY9Gb+0wUMCFsZvcmiz+HigA0LOcq/HoQqVuGG+EKykunc7QG2bzrponfaSw==
@@ -7813,7 +7813,7 @@ import-local@^3.0.2:
78137813
pkg-dir "^4.2.0"
78147814
resolve-cwd "^3.0.0"
78157815

7816-
imurmurhash@*, imurmurhash@^0.1.4:
7816+
imurmurhash@^0.1.4:
78177817
version "0.1.4"
78187818
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
78197819
integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==
@@ -9626,11 +9626,6 @@ lodash._basecreate@^3.0.0:
96269626
resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821"
96279627
integrity sha512-EDem6C9iQpn7fxnGdmhXmqYGjCkStmDXT4AeyB2Ph8WKbglg4aJZczNkQglj+zWXcOEEkViK8THuV2JvugW47g==
96289628

9629-
lodash._baseindexof@*:
9630-
version "3.1.0"
9631-
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
9632-
integrity sha512-bSYo8Pc/f0qAkr8fPJydpJjtrHiSynYfYBjtANIgXv5xEf1WlTC63dIDlgu0s9dmTvzRu1+JJTxcIAHe+sH0FQ==
9633-
96349629
lodash._baseuniq@~4.6.0:
96359630
version "4.6.0"
96369631
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@@ -9639,29 +9634,12 @@ lodash._baseuniq@~4.6.0:
96399634
lodash._createset "~4.0.0"
96409635
lodash._root "~3.0.0"
96419636

9642-
lodash._bindcallback@*:
9643-
version "3.0.1"
9644-
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
9645-
integrity sha512-2wlI0JRAGX8WEf4Gm1p/mv/SZ+jLijpj0jyaE/AXeuQphzCgD8ZQW4oSpoN8JAopujOFGU3KMuq7qfHBWlGpjQ==
9646-
9647-
lodash._cacheindexof@*:
9648-
version "3.0.2"
9649-
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
9650-
integrity sha512-S8dUjWr7SUT/X6TBIQ/OYoCHo1Stu1ZRy6uMUSKqzFnZp5G5RyQizSm6kvxD2Ewyy6AVfMg4AToeZzKfF99T5w==
9651-
9652-
lodash._createcache@*:
9653-
version "3.1.2"
9654-
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
9655-
integrity sha512-ev5SP+iFpZOugyab/DEUQxUeZP5qyciVTlgQ1f4Vlw7VUcCD8fVnyIqVUEIaoFH9zjAqdgi69KiofzvVmda/ZQ==
9656-
dependencies:
9657-
lodash._getnative "^3.0.0"
9658-
96599637
lodash._createset@~4.0.0:
96609638
version "4.0.3"
96619639
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
96629640
integrity sha512-GTkC6YMprrJZCYU3zcqZj+jkXkrXzq3IPBcF/fIPpNEAB4hZEtXU8zp/RwKOvZl43NUmwDbyRk3+ZTbeRdEBXA==
96639641

9664-
lodash._getnative@*, lodash._getnative@^3.0.0:
9642+
lodash._getnative@^3.0.0:
96659643
version "3.9.1"
96669644
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
96679645
integrity sha512-RrL9VxMEPyDMHOd9uFbvMe8X55X16/cGM5IgOKgRElQZutpX89iS6vwl64duTV1/16w5JY7tuFNXqoekmh1EmA==
@@ -9849,11 +9827,6 @@ lodash.reject@^4.4.0:
98499827
resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415"
98509828
integrity sha512-qkTuvgEzYdyhiJBx42YPzPo71R1aEr0z79kAv7Ixg8wPFEjgRgJdUsGMG3Hf3OYSF/kHI79XhNlt+5Ar6OzwxQ==
98519829

9852-
lodash.restparam@*:
9853-
version "3.6.1"
9854-
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
9855-
integrity sha512-L4/arjjuq4noiUJpt3yS6KIKDtJwNe2fIYgMqyYYKoeIfV1iEqvPwhCx23o+R9dzouGihDAPN1dTIRWa7zk8tw==
9856-
98579830
lodash.shuffle@^4.2.0:
98589831
version "4.2.0"
98599832
resolved "https://registry.yarnpkg.com/lodash.shuffle/-/lodash.shuffle-4.2.0.tgz#145b5053cf875f6f5c2a33f48b6e9948c6ec7b4b"

0 commit comments

Comments
 (0)