Skip to content
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

add more tests for react query to increase test coverage #1800

Merged
merged 3 commits into from
Jan 28, 2021

Conversation

zenz34
Copy link
Contributor

@zenz34 zenz34 commented Jan 28, 2021

Coverage now:

------------------|---------|----------|---------|---------|-------------------

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 100 92.31 83.33 100
browser 100 87.5 100 100
index.tsx 100 87.5 100 100 52
common 100 100 0 100
feature-info.ts 100 100 100 100
index.ts 100 100 0 100
node 100 94.44 100 100
index.tsx 100 94.44 100 100 76
------------------ --------- ---------- --------- --------- -------------------

=============================== Coverage summary ===============================
Statements : 100% ( 66/66 )
Branches : 92.31% ( 24/26 )
Functions : 83.33% ( 10/12 )
Lines : 100% ( 64/64 )

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@zenz34 zenz34 changed the title [fix]react query execute error without input component, add more unit tests to increase coverage [fix]react query execute error without input component Jan 28, 2021
)
};
}

const WrapComp = this.wrap({
Copy link
Contributor Author

@zenz34 zenz34 Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find a potential issue while writing unit test for wrap function call here both at browser and node side.

When input.Component is unset, got an error TypeError: subapp_1.envHooks.getContainer(...).get(...)._getExport is not a function
It’s because wrapper component will be gotten through subAppContainer when input.Component is undefined.
Since _getExport function is not required in Typescript declaration, it can be missing. So even we have question mark after that function call _getExported()?, but because it’s undefined, error will be throwed.
Another case is, if getExported is not a function, it will throw an error as well.

So I added several lines above to avoid the error. It simply console.error error msg and returns an component with error message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. it's not needed though.
_getExport is an internal function that the subapp2 engine guarantee to add when user declareSubApp. That's why it has the leading _.
when unit test manually create subapp def for mocking test, it should supply the _getExport if it's needed.
it should return a mock subapp module that has the Component

@zenz34 zenz34 changed the title [fix]react query execute error without input component add more tests for react query to increase test coverage Jan 28, 2021
@jchip jchip merged commit 81aa193 into electrode-io:master Jan 28, 2021
@zenz34 zenz34 deleted the react-query-more-unit-test branch February 3, 2021 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants