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:
Sebastian Rindom
2021-02-03 09:49:12 +01:00
committed by GitHub
parent 0e0dfea571
commit 690d339667
60 changed files with 9429 additions and 189 deletions
@@ -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);
};