-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rework unit tests (mocking the fetch()) #2183
Conversation
4af85a4
to
be3598c
Compare
be3598c
to
7510e15
Compare
c0b79b8
to
de49764
Compare
749d412
to
849eaa5
Compare
a6bf551
to
7ef7825
Compare
fc9f25d
to
de43a0f
Compare
}; | ||
let stubFetcherJson; | ||
before(function () { | ||
stubFetcherJson = sinon.stub(Fetcher, 'json') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could factorize a bit this mocking logic in one place (e.g. in utils.js
) by creating the following method:
function getFetcherStub(method, returnVal) {
sinon.stub(Fetcher, method)
.callsFake(() => Promise.resolve(returnVal));
}
And just do stubFetcherJson = utils.getFetcherStub('json', tileset)
here (and use this method everywhere else where you create stubs). WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of this PR is to get in the direction of real unti tests. Thus i did mock the fetching everywhere, but later on we should be mocking the process that use the mocked fetcher (except for some specifique tests).That's why I think that a it will be on some further PR to think about how to factorize the different mocking parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, in this case could you open an issue about it please ?
22dcc38
to
f5e81ad
Compare
35f88ae
to
a4ca5b7
Compare
This PR propose a rewrite of the unit tests:
Modifications: