feat(medusa,brightpearl,segment,webshipper): claims (#163)
* chore: create tests * chore: models * fix: passing initial tests * test: adds integration test * test: clean up integration implementation * fix: claims * fix: brightpearl + webshipper * tests: passing * fix: update claim items * fix: adds gitignore * fix: pr comments * fix: single migration * fix(medusa-plugin-segment): adds item claimed event to segment
This commit is contained in:
@@ -1,74 +1,93 @@
|
||||
export default ({
|
||||
create,
|
||||
update,
|
||||
remove,
|
||||
softRemove,
|
||||
find,
|
||||
findOne,
|
||||
findOneOrFail,
|
||||
save,
|
||||
findAndCount,
|
||||
} = {}) => {
|
||||
return {
|
||||
create: jest.fn().mockImplementation((...args) => {
|
||||
if (create) {
|
||||
return create(...args);
|
||||
}
|
||||
return {};
|
||||
}),
|
||||
softRemove: jest.fn().mockImplementation((...args) => {
|
||||
if (softRemove) {
|
||||
return softRemove(...args);
|
||||
}
|
||||
return {};
|
||||
}),
|
||||
remove: jest.fn().mockImplementation((...args) => {
|
||||
if (remove) {
|
||||
return remove(...args);
|
||||
}
|
||||
return {};
|
||||
}),
|
||||
update: jest.fn().mockImplementation((...args) => {
|
||||
if (update) {
|
||||
return update(...args);
|
||||
}
|
||||
}),
|
||||
findOneOrFail: jest.fn().mockImplementation((...args) => {
|
||||
if (findOneOrFail) {
|
||||
return findOneOrFail(...args);
|
||||
}
|
||||
}),
|
||||
findOne: jest.fn().mockImplementation((...args) => {
|
||||
if (findOne) {
|
||||
return findOne(...args);
|
||||
}
|
||||
}),
|
||||
findOneOrFail: jest.fn().mockImplementation((...args) => {
|
||||
if (findOneOrFail) {
|
||||
return findOneOrFail(...args);
|
||||
}
|
||||
}),
|
||||
find: jest.fn().mockImplementation((...args) => {
|
||||
if (find) {
|
||||
return find(...args);
|
||||
}
|
||||
}),
|
||||
softRemove: jest.fn().mockImplementation((...args) => {
|
||||
if (softRemove) {
|
||||
return softRemove(...args);
|
||||
}
|
||||
}),
|
||||
save: jest.fn().mockImplementation((...args) => {
|
||||
if (save) {
|
||||
return save(...args);
|
||||
}
|
||||
return Promise.resolve(...args);
|
||||
}),
|
||||
findAndCount: jest.fn().mockImplementation((...args) => {
|
||||
if (findAndCount) {
|
||||
return findAndCount(...args);
|
||||
}
|
||||
return {};
|
||||
}),
|
||||
};
|
||||
class MockRepo {
|
||||
constructor({
|
||||
create,
|
||||
update,
|
||||
remove,
|
||||
softRemove,
|
||||
find,
|
||||
findOne,
|
||||
findOneOrFail,
|
||||
save,
|
||||
findAndCount,
|
||||
}) {
|
||||
this.create_ = create;
|
||||
this.update_ = update;
|
||||
this.remove_ = remove;
|
||||
this.softRemove_ = softRemove;
|
||||
this.find_ = find;
|
||||
this.findOne_ = findOne;
|
||||
this.findOneOrFail_ = findOneOrFail;
|
||||
this.save_ = save;
|
||||
this.findAndCount_ = findAndCount;
|
||||
}
|
||||
|
||||
setFindOne(fn) {
|
||||
this.findOne_ = fn;
|
||||
}
|
||||
|
||||
create = jest.fn().mockImplementation((...args) => {
|
||||
if (this.create_) {
|
||||
return this.create_(...args);
|
||||
}
|
||||
return {};
|
||||
});
|
||||
softRemove = jest.fn().mockImplementation((...args) => {
|
||||
if (this.softRemove_) {
|
||||
return this.softRemove_(...args);
|
||||
}
|
||||
return {};
|
||||
});
|
||||
remove = jest.fn().mockImplementation((...args) => {
|
||||
if (this.remove_) {
|
||||
return this.remove_(...args);
|
||||
}
|
||||
return {};
|
||||
});
|
||||
update = jest.fn().mockImplementation((...args) => {
|
||||
if (this.update_) {
|
||||
return this.update_(...args);
|
||||
}
|
||||
});
|
||||
findOneOrFail = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findOneOrFail_) {
|
||||
return this.findOneOrFail_(...args);
|
||||
}
|
||||
});
|
||||
findOne = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findOne_) {
|
||||
return this.findOne_(...args);
|
||||
}
|
||||
});
|
||||
findOneOrFail = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findOneOrFail_) {
|
||||
return this.findOneOrFail_(...args);
|
||||
}
|
||||
});
|
||||
find = jest.fn().mockImplementation((...args) => {
|
||||
if (this.find_) {
|
||||
return this.find_(...args);
|
||||
}
|
||||
});
|
||||
softRemove = jest.fn().mockImplementation((...args) => {
|
||||
if (this.softRemove_) {
|
||||
return this.softRemove_(...args);
|
||||
}
|
||||
});
|
||||
save = jest.fn().mockImplementation((...args) => {
|
||||
if (this.save_) {
|
||||
return this.save_(...args);
|
||||
}
|
||||
return Promise.resolve(...args);
|
||||
});
|
||||
|
||||
findAndCount = jest.fn().mockImplementation((...args) => {
|
||||
if (this.findAndCount_) {
|
||||
return this.findAndCount_(...args);
|
||||
}
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
||||
export default (methods = {}) => {
|
||||
return new MockRepo(methods);
|
||||
};
|
||||
|
||||
@@ -971,6 +971,18 @@
|
||||
exec-sh "^0.3.2"
|
||||
minimist "^1.2.0"
|
||||
|
||||
"@hapi/hoek@^9.0.0":
|
||||
version "9.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.1.tgz#9daf5745156fd84b8e9889a2dc721f0c58e894aa"
|
||||
integrity sha512-CAEbWH7OIur6jEOzaai83jq3FmKmv4PmX1JYfs9IrYcGEVI/lyL1EXJGCj7eFVJ0bg5QR8LMxBlEtA+xKiLpFw==
|
||||
|
||||
"@hapi/topo@^5.0.0":
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7"
|
||||
integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
|
||||
"@istanbuljs/load-nyc-config@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz#10602de5570baea82f8afbfa2630b24e7a8cfe5b"
|
||||
@@ -1154,6 +1166,23 @@
|
||||
"@types/yargs" "^15.0.0"
|
||||
chalk "^3.0.0"
|
||||
|
||||
"@sideway/address@^4.1.0":
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.0.tgz#0b301ada10ac4e0e3fa525c90615e0b61a72b78d"
|
||||
integrity sha512-wAH/JYRXeIFQRsxerIuLjgUu2Xszam+O5xKeatJ4oudShOOirfmsQ1D6LL54XOU2tizpCYku+s1wmU0SYdpoSA==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
|
||||
"@sideway/formula@^3.0.0":
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
|
||||
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
|
||||
|
||||
"@sideway/pinpoint@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df"
|
||||
integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==
|
||||
|
||||
"@sinonjs/commons@^1.7.0":
|
||||
version "1.7.2"
|
||||
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.7.2.tgz#505f55c74e0272b43f6c52d81946bed7058fc0e2"
|
||||
@@ -3242,6 +3271,22 @@ jest@^25.5.2:
|
||||
import-local "^3.0.2"
|
||||
jest-cli "^25.5.2"
|
||||
|
||||
joi-objectid@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668"
|
||||
integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ==
|
||||
|
||||
joi@^17.3.0:
|
||||
version "17.3.0"
|
||||
resolved "https://registry.yarnpkg.com/joi/-/joi-17.3.0.tgz#f1be4a6ce29bc1716665819ac361dfa139fff5d2"
|
||||
integrity sha512-Qh5gdU6niuYbUIUV5ejbsMiiFmBdw8Kcp8Buj2JntszCkCfxJ9Cz76OtHxOZMPXrt5810iDIXs+n1nNVoquHgg==
|
||||
dependencies:
|
||||
"@hapi/hoek" "^9.0.0"
|
||||
"@hapi/topo" "^5.0.0"
|
||||
"@sideway/address" "^4.1.0"
|
||||
"@sideway/formula" "^3.0.0"
|
||||
"@sideway/pinpoint" "^2.0.0"
|
||||
|
||||
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
@@ -3470,17 +3515,18 @@ map-visit@^1.0.0:
|
||||
dependencies:
|
||||
object-visit "^1.0.0"
|
||||
|
||||
<<<<<<< HEAD
|
||||
math-random@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.4.tgz#5dd6943c938548267016d4e34f057583080c514c"
|
||||
integrity sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==
|
||||
=======
|
||||
memory-pager@^1.0.2:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5"
|
||||
integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==
|
||||
>>>>>>> master
|
||||
|
||||
medusa-core-utils@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.0.tgz#0641b365b769dbf99856025d935eef5cf5d81f2c"
|
||||
integrity sha512-zocRthKhLK3eSjrXbAhZZkIMBRxyvU7GcAMFh5UCEgfe7f935vjE7r5lGTr5jTEwgwaoTUk9ep0VBekz0SEdyw==
|
||||
dependencies:
|
||||
joi "^17.3.0"
|
||||
joi-objectid "^3.0.1"
|
||||
|
||||
merge-stream@^2.0.0:
|
||||
version "2.0.0"
|
||||
|
||||
Reference in New Issue
Block a user