Created
February 24, 2018 11:16
-
-
Save asn007/ae34a550289de8588ef685ab81952374 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QueryBuilderMock { | |
static forClass() { | |
return new this() | |
} | |
modelClass = () => ({ tableName: 'model_mock' }) | |
_mergeContext = jest.fn().mockReturnThis() | |
_patch = jest.fn().mockReturnThis() | |
_delete = jest.fn().mockReturnThis() | |
_where = jest.fn().mockReturnThis() | |
mergeContext(...args) { | |
return this._mergeContext.apply(null, args) | |
} | |
patch(...args) { | |
return this._patch.apply(null, args) | |
} | |
delete(...args) { | |
return this._delete.apply(null, args) | |
} | |
where(...args) { | |
return this._where.apply(null, args) | |
} | |
} | |
class ModelMock { | |
static query() { | |
return this.QueryBuilder.forClass(this) | |
} | |
static get QueryBuilder() { | |
return QueryBuilderMock | |
} | |
static namedFilters = { | |
someFilter: () => {}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment