feed-common 1.49.2 → 1.49.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/dist/constants/profile.constants.d.ts +1 -2
- package/dist/constants/profile.constants.d.ts.map +1 -1
- package/dist/constants/profile.constants.js +145 -145
- package/dist/constants/profile.constants.js.map +1 -1
- package/dist/types/profile.types.d.ts +3 -5
- package/dist/types/profile.types.d.ts.map +1 -1
- package/dist/utils/feed-templates/facebook.template.d.ts.map +1 -1
- package/dist/utils/feed-templates/facebook.template.js +2 -0
- package/dist/utils/feed-templates/facebook.template.js.map +1 -1
- package/dist/utils/feed-templates/google-api.template.d.ts.map +1 -1
- package/dist/utils/feed-templates/google-api.template.js +8 -0
- package/dist/utils/feed-templates/google-api.template.js.map +1 -1
- package/dist/utils/feed-templates/google.template.d.ts.map +1 -1
- package/dist/utils/feed-templates/google.template.js +10 -0
- package/dist/utils/feed-templates/google.template.js.map +1 -1
- package/dist/utils/feed-templates/microsoft.template.d.ts.map +1 -1
- package/dist/utils/feed-templates/microsoft.template.js +3 -0
- package/dist/utils/feed-templates/microsoft.template.js.map +1 -1
- package/dist/utils/feed-templates/tiktok.template.d.ts.map +1 -1
- package/dist/utils/feed-templates/tiktok.template.js +2 -0
- package/dist/utils/feed-templates/tiktok.template.js.map +1 -1
- package/dist/utils/profile.d.ts +0 -7
- package/dist/utils/profile.d.ts.map +1 -1
- package/dist/utils/profile.js +57 -52
- package/dist/utils/profile.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/profile.constants.ts +147 -146
- package/src/types/profile.types.ts +3 -5
- package/src/utils/feed-templates/facebook.template.ts +2 -0
- package/src/utils/feed-templates/google-api.template.ts +8 -0
- package/src/utils/feed-templates/google.template.ts +10 -0
- package/src/utils/feed-templates/microsoft.template.ts +3 -0
- package/src/utils/feed-templates/tiktok.template.ts +2 -0
- package/src/utils/profile.ts +62 -62
- package/tests/profile.spec.ts +765 -755
package/tests/profile.spec.ts
CHANGED
@@ -6,13 +6,12 @@ import {
|
|
6
6
|
checkRuleDuplication,
|
7
7
|
compareMappings,
|
8
8
|
compareRules,
|
9
|
-
detectProfileChange,
|
10
9
|
getOperatorCounterpart,
|
11
10
|
hasRules,
|
12
11
|
sanitizeUploadProfile,
|
13
|
-
sortMappings,
|
14
12
|
} from '../src/utils/profile.js';
|
15
13
|
import { ProductUploadMapping, ProductUploadProfile } from '../src/types/profile.types.js';
|
14
|
+
import { XmlFeedFormat, XMLFeedType } from '../src/constants/profile.constants.js';
|
16
15
|
|
17
16
|
describe('Rules duplication', () => {
|
18
17
|
test('no match', () => {
|
@@ -226,33 +225,33 @@ describe('Operators counterpart', () => {
|
|
226
225
|
});
|
227
226
|
});
|
228
227
|
|
229
|
-
describe('Mappings sort', () => {
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
});
|
228
|
+
// describe('Mappings sort', () => {
|
229
|
+
// test('Test', () => {
|
230
|
+
// expect(
|
231
|
+
// [
|
232
|
+
// {} as ProductUploadMapping,
|
233
|
+
// { attribute: 'contentLanguage' } as ProductUploadMapping,
|
234
|
+
// { attribute: 'targetCountry' } as ProductUploadMapping,
|
235
|
+
// { attribute: 'title' } as ProductUploadMapping,
|
236
|
+
// { attribute: 'adult' } as ProductUploadMapping,
|
237
|
+
// { attribute: 'ageGroup' } as ProductUploadMapping,
|
238
|
+
// { attribute: 'availability' } as ProductUploadMapping,
|
239
|
+
// { attribute: 'title' } as ProductUploadMapping,
|
240
|
+
// ]
|
241
|
+
// .sort(sortMappings)
|
242
|
+
// .map(m => m.attribute)
|
243
|
+
// ).toEqual([
|
244
|
+
// 'availability',
|
245
|
+
// 'contentLanguage',
|
246
|
+
// 'targetCountry',
|
247
|
+
// 'adult',
|
248
|
+
// 'ageGroup',
|
249
|
+
// 'title',
|
250
|
+
// 'title',
|
251
|
+
// undefined,
|
252
|
+
// ]);
|
253
|
+
// });
|
254
|
+
// });
|
256
255
|
|
257
256
|
describe('Has rules', () => {
|
258
257
|
test('match', () => {
|
@@ -694,731 +693,742 @@ describe('Compare mappings', () => {
|
|
694
693
|
});
|
695
694
|
});
|
696
695
|
|
697
|
-
describe('Detect profile change', () => {
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
}
|
696
|
+
// describe('Detect profile change', () => {
|
697
|
+
// test('No changes', () => {
|
698
|
+
// const profileA = {
|
699
|
+
// id: '1',
|
700
|
+
// profileIdTemplate: '1',
|
701
|
+
// name: 'profileA',
|
702
|
+
// rules: {
|
703
|
+
// sections: [
|
704
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
705
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
706
|
+
// ],
|
707
|
+
// },
|
708
|
+
// mappings: [
|
709
|
+
// {
|
710
|
+
// attribute: 'contentLanguage',
|
711
|
+
// value: 'en',
|
712
|
+
// rules: {
|
713
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
714
|
+
// },
|
715
|
+
// },
|
716
|
+
// {
|
717
|
+
// attribute: 'ageGroup',
|
718
|
+
// value: 'newborn',
|
719
|
+
// rules: {
|
720
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
721
|
+
// },
|
722
|
+
// },
|
723
|
+
// ],
|
724
|
+
// } as ProductUploadProfile;
|
725
|
+
|
726
|
+
// const profileB = {
|
727
|
+
// id: '1',
|
728
|
+
// profileIdTemplate: '1',
|
729
|
+
// name: 'profileA',
|
730
|
+
// rules: {
|
731
|
+
// sections: [
|
732
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
733
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
734
|
+
// ],
|
735
|
+
// },
|
736
|
+
// mappings: [
|
737
|
+
// {
|
738
|
+
// attribute: 'contentLanguage',
|
739
|
+
// value: 'en',
|
740
|
+
// rules: {
|
741
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
742
|
+
// },
|
743
|
+
// },
|
744
|
+
// {
|
745
|
+
// attribute: 'ageGroup',
|
746
|
+
// value: 'newborn',
|
747
|
+
// rules: {
|
748
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
749
|
+
// },
|
750
|
+
// },
|
751
|
+
// ],
|
752
|
+
// } as ProductUploadProfile;
|
753
|
+
|
754
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
755
|
+
// name: false,
|
756
|
+
// rules: false,
|
757
|
+
// mappings: false,
|
758
|
+
// id: false,
|
759
|
+
// });
|
760
|
+
// });
|
761
|
+
|
762
|
+
// test('Name change', () => {
|
763
|
+
// const profileA = {
|
764
|
+
// id: '1',
|
765
|
+
// profileIdTemplate: '1',
|
766
|
+
// name: 'profileA',
|
767
|
+
// rules: {
|
768
|
+
// sections: [
|
769
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
770
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
771
|
+
// ],
|
772
|
+
// },
|
773
|
+
// mappings: [
|
774
|
+
// {
|
775
|
+
// attribute: 'contentLanguage',
|
776
|
+
// value: 'en',
|
777
|
+
// rules: {
|
778
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
779
|
+
// },
|
780
|
+
// },
|
781
|
+
// {
|
782
|
+
// attribute: 'ageGroup',
|
783
|
+
// value: 'newborn',
|
784
|
+
// rules: {
|
785
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
786
|
+
// },
|
787
|
+
// },
|
788
|
+
// ],
|
789
|
+
// } as ProductUploadProfile;
|
790
|
+
|
791
|
+
// const profileB = {
|
792
|
+
// id: '1',
|
793
|
+
// profileIdTemplate: '1',
|
794
|
+
// name: 'profileB',
|
795
|
+
// rules: {
|
796
|
+
// sections: [
|
797
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
798
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
799
|
+
// ],
|
800
|
+
// },
|
801
|
+
// mappings: [
|
802
|
+
// {
|
803
|
+
// attribute: 'contentLanguage',
|
804
|
+
// value: 'en',
|
805
|
+
// rules: {
|
806
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
807
|
+
// },
|
808
|
+
// },
|
809
|
+
// {
|
810
|
+
// attribute: 'ageGroup',
|
811
|
+
// value: 'newborn',
|
812
|
+
// rules: {
|
813
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
814
|
+
// },
|
815
|
+
// },
|
816
|
+
// ],
|
817
|
+
// } as ProductUploadProfile;
|
818
|
+
|
819
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
820
|
+
// name: true,
|
821
|
+
// rules: false,
|
822
|
+
// mappings: false,
|
823
|
+
// id: false,
|
824
|
+
// });
|
825
|
+
// });
|
826
|
+
|
827
|
+
// test('Mappings change #1', () => {
|
828
|
+
// const profileA = {
|
829
|
+
// id: '1',
|
830
|
+
// profileIdTemplate: '1',
|
831
|
+
// name: 'profileA',
|
832
|
+
// rules: {
|
833
|
+
// sections: [
|
834
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
835
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
836
|
+
// ],
|
837
|
+
// },
|
838
|
+
// mappings: [
|
839
|
+
// {
|
840
|
+
// attribute: 'contentLanguage',
|
841
|
+
// value: 'en',
|
842
|
+
// rules: {
|
843
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
844
|
+
// },
|
845
|
+
// },
|
846
|
+
// {
|
847
|
+
// attribute: 'ageGroup',
|
848
|
+
// value: 'newborn',
|
849
|
+
// rules: {
|
850
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
851
|
+
// },
|
852
|
+
// },
|
853
|
+
// ],
|
854
|
+
// } as ProductUploadProfile;
|
855
|
+
|
856
|
+
// const profileB = {
|
857
|
+
// id: '1',
|
858
|
+
// profileIdTemplate: '1',
|
859
|
+
// name: 'profileA',
|
860
|
+
// rules: {
|
861
|
+
// sections: [
|
862
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
863
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
864
|
+
// ],
|
865
|
+
// },
|
866
|
+
// mappings: [
|
867
|
+
// {
|
868
|
+
// attribute: 'contentLanguage',
|
869
|
+
// value: 'en',
|
870
|
+
// rules: {
|
871
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
872
|
+
// },
|
873
|
+
// },
|
874
|
+
// {
|
875
|
+
// attribute: 'brand',
|
876
|
+
// value: 'Voxhall',
|
877
|
+
// rules: {
|
878
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
879
|
+
// },
|
880
|
+
// },
|
881
|
+
// ],
|
882
|
+
// } as ProductUploadProfile;
|
883
|
+
|
884
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
885
|
+
// name: false,
|
886
|
+
// rules: false,
|
887
|
+
// mappings: true,
|
888
|
+
// id: false,
|
889
|
+
// });
|
890
|
+
// });
|
891
|
+
|
892
|
+
// test('Mappings change #2', () => {
|
893
|
+
// const profileA = {
|
894
|
+
// id: '1',
|
895
|
+
// profileIdTemplate: '1',
|
896
|
+
// name: 'profileA',
|
897
|
+
// rules: {
|
898
|
+
// sections: [
|
899
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
900
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
901
|
+
// ],
|
902
|
+
// },
|
903
|
+
// mappings: [
|
904
|
+
// {
|
905
|
+
// attribute: 'contentLanguage',
|
906
|
+
// value: 'en',
|
907
|
+
// rules: {
|
908
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
909
|
+
// },
|
910
|
+
// },
|
911
|
+
// {
|
912
|
+
// attribute: 'ageGroup',
|
913
|
+
// value: 'newborn',
|
914
|
+
// rules: {
|
915
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
916
|
+
// },
|
917
|
+
// },
|
918
|
+
// ],
|
919
|
+
// } as ProductUploadProfile;
|
920
|
+
|
921
|
+
// const profileB = {
|
922
|
+
// id: '1',
|
923
|
+
// profileIdTemplate: '1',
|
924
|
+
// name: 'profileA',
|
925
|
+
// rules: {
|
926
|
+
// sections: [
|
927
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
928
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
929
|
+
// ],
|
930
|
+
// },
|
931
|
+
// mappings: [
|
932
|
+
// {
|
933
|
+
// attribute: 'contentLanguage',
|
934
|
+
// value: 'en',
|
935
|
+
// rules: {
|
936
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
937
|
+
// },
|
938
|
+
// },
|
939
|
+
// {
|
940
|
+
// attribute: 'ageGroup',
|
941
|
+
// value: 'newborn',
|
942
|
+
// rules: {
|
943
|
+
// sections: [
|
944
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
945
|
+
// ],
|
946
|
+
// },
|
947
|
+
// },
|
948
|
+
// ],
|
949
|
+
// } as ProductUploadProfile;
|
950
|
+
|
951
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
952
|
+
// name: false,
|
953
|
+
// rules: false,
|
954
|
+
// mappings: true,
|
955
|
+
// id: false,
|
956
|
+
// });
|
957
|
+
// });
|
958
|
+
|
959
|
+
// test('ID section change #1', () => {
|
960
|
+
// const profileA = {
|
961
|
+
// id: '1',
|
962
|
+
// profileIdTemplate: '1',
|
963
|
+
// name: 'profileA',
|
964
|
+
// rules: {
|
965
|
+
// sections: [
|
966
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
967
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
968
|
+
// ],
|
969
|
+
// },
|
970
|
+
// mappings: [
|
971
|
+
// {
|
972
|
+
// attribute: 'contentLanguage',
|
973
|
+
// value: 'en',
|
974
|
+
// rules: {
|
975
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
976
|
+
// },
|
977
|
+
// },
|
978
|
+
// {
|
979
|
+
// attribute: 'ageGroup',
|
980
|
+
// value: 'newborn',
|
981
|
+
// rules: {
|
982
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
983
|
+
// },
|
984
|
+
// },
|
985
|
+
// ],
|
986
|
+
// } as ProductUploadProfile;
|
987
|
+
|
988
|
+
// const profileB = {
|
989
|
+
// id: '1',
|
990
|
+
// profileIdTemplate: '1',
|
991
|
+
// name: 'profileA',
|
992
|
+
// rules: {
|
993
|
+
// sections: [
|
994
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
995
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
996
|
+
// ],
|
997
|
+
// },
|
998
|
+
// mappings: [
|
999
|
+
// {
|
1000
|
+
// attribute: 'gender',
|
1001
|
+
// value: 'male',
|
1002
|
+
// rules: {
|
1003
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1004
|
+
// },
|
1005
|
+
// },
|
1006
|
+
// {
|
1007
|
+
// attribute: 'ageGroup',
|
1008
|
+
// value: 'newborn',
|
1009
|
+
// rules: {
|
1010
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1011
|
+
// },
|
1012
|
+
// },
|
1013
|
+
// ],
|
1014
|
+
// } as ProductUploadProfile;
|
1015
|
+
|
1016
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
1017
|
+
// name: false,
|
1018
|
+
// rules: false,
|
1019
|
+
// mappings: true,
|
1020
|
+
// id: true,
|
1021
|
+
// });
|
1022
|
+
// });
|
1023
|
+
|
1024
|
+
// test('ID section change #2', () => {
|
1025
|
+
// const profileA = {
|
1026
|
+
// id: '1',
|
1027
|
+
// profileIdTemplate: '1',
|
1028
|
+
// name: 'profileA',
|
1029
|
+
// rules: {
|
1030
|
+
// sections: [
|
1031
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1032
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1033
|
+
// ],
|
1034
|
+
// },
|
1035
|
+
// mappings: [
|
1036
|
+
// {
|
1037
|
+
// attribute: 'contentLanguage',
|
1038
|
+
// value: 'en',
|
1039
|
+
// rules: {
|
1040
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1041
|
+
// },
|
1042
|
+
// },
|
1043
|
+
// {
|
1044
|
+
// attribute: 'ageGroup',
|
1045
|
+
// value: 'newborn',
|
1046
|
+
// rules: {
|
1047
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1048
|
+
// },
|
1049
|
+
// },
|
1050
|
+
// ],
|
1051
|
+
// } as ProductUploadProfile;
|
1052
|
+
|
1053
|
+
// const profileB = {
|
1054
|
+
// id: '1',
|
1055
|
+
// profileIdTemplate: '1',
|
1056
|
+
// name: 'profileA',
|
1057
|
+
// rules: {
|
1058
|
+
// sections: [
|
1059
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1060
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1061
|
+
// ],
|
1062
|
+
// },
|
1063
|
+
// mappings: [
|
1064
|
+
// {
|
1065
|
+
// attribute: 'contentLanguage',
|
1066
|
+
// value: 'en',
|
1067
|
+
// rules: {
|
1068
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
|
1069
|
+
// },
|
1070
|
+
// },
|
1071
|
+
// {
|
1072
|
+
// attribute: 'ageGroup',
|
1073
|
+
// value: 'newborn',
|
1074
|
+
// rules: {
|
1075
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1076
|
+
// },
|
1077
|
+
// },
|
1078
|
+
// ],
|
1079
|
+
// } as ProductUploadProfile;
|
1080
|
+
|
1081
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
1082
|
+
// name: false,
|
1083
|
+
// rules: false,
|
1084
|
+
// mappings: false,
|
1085
|
+
// id: true,
|
1086
|
+
// });
|
1087
|
+
// });
|
1088
|
+
|
1089
|
+
// test('Mapping change #1', () => {
|
1090
|
+
// const profileA = {
|
1091
|
+
// id: '1',
|
1092
|
+
// profileIdTemplate: '1',
|
1093
|
+
// name: 'profileA',
|
1094
|
+
// rules: {
|
1095
|
+
// sections: [
|
1096
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1097
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1098
|
+
// ],
|
1099
|
+
// },
|
1100
|
+
// mappings: [
|
1101
|
+
// {
|
1102
|
+
// attribute: 'contentLanguage',
|
1103
|
+
// value: 'en',
|
1104
|
+
// rules: {
|
1105
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1106
|
+
// },
|
1107
|
+
// },
|
1108
|
+
// {
|
1109
|
+
// attribute: 'ageGroup',
|
1110
|
+
// value: 'newborn',
|
1111
|
+
// rules: {
|
1112
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1113
|
+
// },
|
1114
|
+
// },
|
1115
|
+
// ],
|
1116
|
+
// } as ProductUploadProfile;
|
1117
|
+
|
1118
|
+
// const profileB = {
|
1119
|
+
// id: '1',
|
1120
|
+
// profileIdTemplate: '1',
|
1121
|
+
// name: 'profileA',
|
1122
|
+
// rules: {
|
1123
|
+
// sections: [
|
1124
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1125
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1126
|
+
// ],
|
1127
|
+
// },
|
1128
|
+
// mappings: [
|
1129
|
+
// {
|
1130
|
+
// attribute: 'contentLanguage',
|
1131
|
+
// value: 'en',
|
1132
|
+
// rules: {
|
1133
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1134
|
+
// },
|
1135
|
+
// },
|
1136
|
+
// {
|
1137
|
+
// attribute: 'ageGroup',
|
1138
|
+
// value: 'newborn',
|
1139
|
+
// rules: {
|
1140
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1141
|
+
// },
|
1142
|
+
// },
|
1143
|
+
// {
|
1144
|
+
// attribute: 'adult',
|
1145
|
+
// value: true,
|
1146
|
+
// rules: {
|
1147
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1148
|
+
// },
|
1149
|
+
// },
|
1150
|
+
// ],
|
1151
|
+
// } as ProductUploadProfile;
|
1152
|
+
|
1153
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
1154
|
+
// name: false,
|
1155
|
+
// rules: false,
|
1156
|
+
// mappings: true,
|
1157
|
+
// id: false,
|
1158
|
+
// });
|
1159
|
+
// });
|
1160
|
+
|
1161
|
+
// test('Mapping change #2', () => {
|
1162
|
+
// const profileA = {
|
1163
|
+
// id: '1',
|
1164
|
+
// profileIdTemplate: '1',
|
1165
|
+
// name: 'profileA',
|
1166
|
+
// rules: {
|
1167
|
+
// sections: [
|
1168
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1169
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1170
|
+
// ],
|
1171
|
+
// },
|
1172
|
+
// mappings: [
|
1173
|
+
// {
|
1174
|
+
// attribute: 'contentLanguage',
|
1175
|
+
// value: 'en',
|
1176
|
+
// rules: {
|
1177
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1178
|
+
// },
|
1179
|
+
// },
|
1180
|
+
// {
|
1181
|
+
// attribute: 'ageGroup',
|
1182
|
+
// value: 'newborn',
|
1183
|
+
// rules: {
|
1184
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1185
|
+
// },
|
1186
|
+
// },
|
1187
|
+
// ],
|
1188
|
+
// } as ProductUploadProfile;
|
1189
|
+
|
1190
|
+
// const profileB = {
|
1191
|
+
// id: '1',
|
1192
|
+
// profileIdTemplate: '1',
|
1193
|
+
// name: 'profileA',
|
1194
|
+
// rules: {
|
1195
|
+
// sections: [
|
1196
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1197
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1198
|
+
// ],
|
1199
|
+
// },
|
1200
|
+
// mappings: [
|
1201
|
+
// {
|
1202
|
+
// attribute: 'contentLanguage',
|
1203
|
+
// value: 'en',
|
1204
|
+
// rules: {
|
1205
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1206
|
+
// },
|
1207
|
+
// },
|
1208
|
+
// {
|
1209
|
+
// attribute: 'adult',
|
1210
|
+
// value: true,
|
1211
|
+
// rules: {
|
1212
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1213
|
+
// },
|
1214
|
+
// },
|
1215
|
+
// ],
|
1216
|
+
// } as ProductUploadProfile;
|
1217
|
+
|
1218
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
1219
|
+
// name: false,
|
1220
|
+
// rules: false,
|
1221
|
+
// mappings: true,
|
1222
|
+
// id: false,
|
1223
|
+
// });
|
1224
|
+
// });
|
1225
|
+
|
1226
|
+
// test('Mappings change #3', () => {
|
1227
|
+
// const profileA = {
|
1228
|
+
// id: '1',
|
1229
|
+
// profileIdTemplate: '1',
|
1230
|
+
// name: 'profileA',
|
1231
|
+
// rules: {
|
1232
|
+
// sections: [
|
1233
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1234
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1235
|
+
// ],
|
1236
|
+
// },
|
1237
|
+
// mappings: [
|
1238
|
+
// {
|
1239
|
+
// attribute: 'contentLanguage',
|
1240
|
+
// value: 'en',
|
1241
|
+
// rules: {
|
1242
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1243
|
+
// },
|
1244
|
+
// },
|
1245
|
+
// {
|
1246
|
+
// attribute: 'ageGroup',
|
1247
|
+
// value: 'newborn',
|
1248
|
+
// rules: {
|
1249
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1250
|
+
// },
|
1251
|
+
// },
|
1252
|
+
// ],
|
1253
|
+
// } as ProductUploadProfile;
|
1254
|
+
|
1255
|
+
// const profileB = {
|
1256
|
+
// id: '1',
|
1257
|
+
// profileIdTemplate: '1',
|
1258
|
+
// name: 'profileA',
|
1259
|
+
// rules: {
|
1260
|
+
// sections: [
|
1261
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1262
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1263
|
+
// ],
|
1264
|
+
// },
|
1265
|
+
// mappings: [
|
1266
|
+
// {
|
1267
|
+
// attribute: 'contentLanguage',
|
1268
|
+
// value: 'en',
|
1269
|
+
// rules: {
|
1270
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1271
|
+
// },
|
1272
|
+
// },
|
1273
|
+
// {
|
1274
|
+
// attribute: 'ageGroup',
|
1275
|
+
// value: 'newborn',
|
1276
|
+
// rules: {
|
1277
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: 'title1' }] }],
|
1278
|
+
// },
|
1279
|
+
// },
|
1280
|
+
// ],
|
1281
|
+
// } as ProductUploadProfile;
|
1282
|
+
|
1283
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
1284
|
+
// name: false,
|
1285
|
+
// rules: false,
|
1286
|
+
// mappings: true,
|
1287
|
+
// id: false,
|
1288
|
+
// });
|
1289
|
+
// });
|
1290
|
+
|
1291
|
+
// test('Rules change', () => {
|
1292
|
+
// const profileA = {
|
1293
|
+
// id: '1',
|
1294
|
+
// profileIdTemplate: '1',
|
1295
|
+
// name: 'profileA',
|
1296
|
+
// rules: {
|
1297
|
+
// sections: [
|
1298
|
+
// { id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1299
|
+
// { id: '1', ruleItems: [{ id: '1', attribute: 'price', operator: 'less', value: 100 }] },
|
1300
|
+
// ],
|
1301
|
+
// },
|
1302
|
+
// mappings: [
|
1303
|
+
// {
|
1304
|
+
// id: '1',
|
1305
|
+
// attribute: 'contentLanguage',
|
1306
|
+
// value: 'en',
|
1307
|
+
// rules: {
|
1308
|
+
// sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1309
|
+
// },
|
1310
|
+
// },
|
1311
|
+
// {
|
1312
|
+
// id: '1',
|
1313
|
+
// attribute: 'ageGroup',
|
1314
|
+
// value: 'newborn',
|
1315
|
+
// rules: {
|
1316
|
+
// sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1317
|
+
// },
|
1318
|
+
// },
|
1319
|
+
// ],
|
1320
|
+
// defaultValue: '',
|
1321
|
+
// type: XMLFeedType.Google,
|
1322
|
+
// format: XmlFeedFormat.XML,
|
1323
|
+
// active: true,
|
1324
|
+
// } as ProductUploadProfile;
|
1325
|
+
|
1326
|
+
// const profileB = {
|
1327
|
+
// id: '1',
|
1328
|
+
// name: 'profileA',
|
1329
|
+
// rules: {
|
1330
|
+
// sections: [
|
1331
|
+
// { id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1332
|
+
// { id: '1', ruleItems: [{ id: '1', attribute: 'price', operator: 'less', value: 101 }] },
|
1333
|
+
// ],
|
1334
|
+
// },
|
1335
|
+
// mappings: [
|
1336
|
+
// {
|
1337
|
+
// id: '1',
|
1338
|
+
// attribute: 'contentLanguage',
|
1339
|
+
// value: 'en',
|
1340
|
+
// rules: {
|
1341
|
+
// sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1342
|
+
// },
|
1343
|
+
// },
|
1344
|
+
// {
|
1345
|
+
// id: '2',
|
1346
|
+
// attribute: 'ageGroup',
|
1347
|
+
// value: 'newborn',
|
1348
|
+
// rules: {
|
1349
|
+
// sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1350
|
+
// },
|
1351
|
+
// },
|
1352
|
+
// ],
|
1353
|
+
// defaultValue: '',
|
1354
|
+
// type: XMLFeedType.Google,
|
1355
|
+
// format: XmlFeedFormat.XML,
|
1356
|
+
// active: true,
|
1357
|
+
// } as ProductUploadProfile;
|
1358
|
+
|
1359
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
1360
|
+
// name: false,
|
1361
|
+
// rules: true,
|
1362
|
+
// mappings: false,
|
1363
|
+
// id: false,
|
1364
|
+
// });
|
1365
|
+
// });
|
1366
|
+
|
1367
|
+
// test('All changed', () => {
|
1368
|
+
// const profileA = {
|
1369
|
+
// id: '1',
|
1370
|
+
// profileIdTemplate: '1',
|
1371
|
+
// name: 'profileA',
|
1372
|
+
// rules: {
|
1373
|
+
// sections: [
|
1374
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1375
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 100 }] },
|
1376
|
+
// ],
|
1377
|
+
// },
|
1378
|
+
// mappings: [
|
1379
|
+
// {
|
1380
|
+
// attribute: 'contentLanguage',
|
1381
|
+
// value: 'en',
|
1382
|
+
// rules: {
|
1383
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1384
|
+
// },
|
1385
|
+
// },
|
1386
|
+
// {
|
1387
|
+
// attribute: 'ageGroup',
|
1388
|
+
// value: 'newborn',
|
1389
|
+
// rules: {
|
1390
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1'] }] }],
|
1391
|
+
// },
|
1392
|
+
// },
|
1393
|
+
// ],
|
1394
|
+
// } as ProductUploadProfile;
|
1395
|
+
|
1396
|
+
// const profileB = {
|
1397
|
+
// id: '1',
|
1398
|
+
// profileIdTemplate: '1',
|
1399
|
+
// name: 'profileB',
|
1400
|
+
// rules: {
|
1401
|
+
// sections: [
|
1402
|
+
// { ruleItems: [{ attribute: 'title', operator: 'in', value: ['title1', 'title2'] }] },
|
1403
|
+
// { ruleItems: [{ attribute: 'price', operator: 'less', value: 101 }] },
|
1404
|
+
// ],
|
1405
|
+
// },
|
1406
|
+
// mappings: [
|
1407
|
+
// {
|
1408
|
+
// attribute: 'contentLanguage',
|
1409
|
+
// value: 'en',
|
1410
|
+
// rules: {
|
1411
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
|
1412
|
+
// },
|
1413
|
+
// },
|
1414
|
+
// {
|
1415
|
+
// attribute: 'ageGroup',
|
1416
|
+
// value: 'newborn',
|
1417
|
+
// rules: {
|
1418
|
+
// sections: [{ ruleItems: [{ attribute: 'title', operator: 'in', value: ['title2'] }] }],
|
1419
|
+
// },
|
1420
|
+
// },
|
1421
|
+
// ],
|
1422
|
+
// } as ProductUploadProfile;
|
1423
|
+
|
1424
|
+
// expect(detectProfileChange(profileA, profileB)).toEqual({
|
1425
|
+
// name: true,
|
1426
|
+
// rules: true,
|
1427
|
+
// mappings: true,
|
1428
|
+
// id: true,
|
1429
|
+
// });
|
1430
|
+
// });
|
1431
|
+
// });
|
1422
1432
|
|
1423
1433
|
describe('Sanitize upload profile', () => {
|
1424
1434
|
test('Test #1', () => {
|
@@ -1453,7 +1463,7 @@ describe('Sanitize upload profile', () => {
|
|
1453
1463
|
},
|
1454
1464
|
},
|
1455
1465
|
],
|
1456
|
-
} as
|
1466
|
+
} as any)
|
1457
1467
|
).toEqual({
|
1458
1468
|
id: '1',
|
1459
1469
|
profileIdTemplate: '1',
|