New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

medusa-test-utils

Package Overview
Dependencies
Maintainers
2
Versions
1627
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

medusa-test-utils - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [1.1.2](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.1...medusa-test-utils@1.1.2) (2021-02-03)
### Features
* **medusa,brightpearl,segment,webshipper:** claims ([#163](https://github.com/medusajs/medusa/issues/163)) ([690d339](https://github.com/medusajs/medusa/commit/690d33966754a7dbe159c3ac09712a3c3bfaff0b))
## [1.1.1](https://github.com/medusajs/medusa/compare/medusa-test-utils@1.1.0...medusa-test-utils@1.1.1) (2021-01-27)

@@ -8,0 +19,0 @@

166

dist/mock-repository.js

@@ -8,82 +8,130 @@ "use strict";

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _default = function _default() {
var _ref2;
var MockRepo =
/*#__PURE__*/
function () {
function MockRepo(_ref) {
var _this = this;
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
create = _ref.create,
update = _ref.update,
remove = _ref.remove,
softRemove = _ref.softRemove,
find = _ref.find,
findOne = _ref.findOne,
findOneOrFail = _ref.findOneOrFail,
save = _ref.save,
findAndCount = _ref.findAndCount;
var create = _ref.create,
update = _ref.update,
remove = _ref.remove,
softRemove = _ref.softRemove,
find = _ref.find,
findOne = _ref.findOne,
findOneOrFail = _ref.findOneOrFail,
save = _ref.save,
findAndCount = _ref.findAndCount;
return _ref2 = {
create: jest.fn().mockImplementation(function () {
if (create) {
return create.apply(void 0, arguments);
_classCallCheck(this, MockRepo);
_defineProperty(this, "create", jest.fn().mockImplementation(function () {
if (_this.create_) {
return _this.create_.apply(_this, arguments);
}
return {};
}),
softRemove: jest.fn().mockImplementation(function () {
if (softRemove) {
return softRemove.apply(void 0, arguments);
}));
_defineProperty(this, "softRemove", jest.fn().mockImplementation(function () {
if (_this.softRemove_) {
return _this.softRemove_.apply(_this, arguments);
}
return {};
}),
remove: jest.fn().mockImplementation(function () {
if (remove) {
return remove.apply(void 0, arguments);
}));
_defineProperty(this, "remove", jest.fn().mockImplementation(function () {
if (_this.remove_) {
return _this.remove_.apply(_this, arguments);
}
return {};
}),
update: jest.fn().mockImplementation(function () {
if (update) {
return update.apply(void 0, arguments);
}));
_defineProperty(this, "update", jest.fn().mockImplementation(function () {
if (_this.update_) {
return _this.update_.apply(_this, arguments);
}
}),
findOneOrFail: jest.fn().mockImplementation(function () {
if (findOneOrFail) {
return findOneOrFail.apply(void 0, arguments);
}));
_defineProperty(this, "findOneOrFail", jest.fn().mockImplementation(function () {
if (_this.findOneOrFail_) {
return _this.findOneOrFail_.apply(_this, arguments);
}
}),
findOne: jest.fn().mockImplementation(function () {
if (findOne) {
return findOne.apply(void 0, arguments);
}));
_defineProperty(this, "findOne", jest.fn().mockImplementation(function () {
if (_this.findOne_) {
return _this.findOne_.apply(_this, arguments);
}
})
}, _defineProperty(_ref2, "findOneOrFail", jest.fn().mockImplementation(function () {
if (findOneOrFail) {
return findOneOrFail.apply(void 0, arguments);
}
})), _defineProperty(_ref2, "find", jest.fn().mockImplementation(function () {
if (find) {
return find.apply(void 0, arguments);
}
})), _defineProperty(_ref2, "softRemove", jest.fn().mockImplementation(function () {
if (softRemove) {
return softRemove.apply(void 0, arguments);
}
})), _defineProperty(_ref2, "save", jest.fn().mockImplementation(function () {
if (save) {
return save.apply(void 0, arguments);
}
}));
return Promise.resolve.apply(Promise, arguments);
})), _defineProperty(_ref2, "findAndCount", jest.fn().mockImplementation(function () {
if (findAndCount) {
return findAndCount.apply(void 0, arguments);
_defineProperty(this, "findOneOrFail", jest.fn().mockImplementation(function () {
if (_this.findOneOrFail_) {
return _this.findOneOrFail_.apply(_this, arguments);
}
}));
_defineProperty(this, "find", jest.fn().mockImplementation(function () {
if (_this.find_) {
return _this.find_.apply(_this, arguments);
}
}));
_defineProperty(this, "softRemove", jest.fn().mockImplementation(function () {
if (_this.softRemove_) {
return _this.softRemove_.apply(_this, arguments);
}
}));
_defineProperty(this, "save", jest.fn().mockImplementation(function () {
if (_this.save_) {
return _this.save_.apply(_this, arguments);
}
return Promise.resolve.apply(Promise, arguments);
}));
_defineProperty(this, "findAndCount", jest.fn().mockImplementation(function () {
if (_this.findAndCount_) {
return _this.findAndCount_.apply(_this, arguments);
}
return {};
}));
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;
}
_createClass(MockRepo, [{
key: "setFindOne",
value: function setFindOne(fn) {
this.findOne_ = fn;
}
}]);
return {};
})), _ref2;
return MockRepo;
}();
var _default = function _default() {
var methods = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return new MockRepo(methods);
};
exports["default"] = _default;
{
"name": "medusa-test-utils",
"version": "1.1.1",
"version": "1.1.2",
"description": "Test utils for Medusa",

@@ -35,3 +35,3 @@ "main": "dist/index.js",

},
"gitHead": "dc210c2cbd71ab8b94149cac58654fb77b3473d9"
"gitHead": "698c63da8ad416ad48aae6e916776c1f3fecb2f9"
}

@@ -1,74 +0,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);
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc