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

adds test for token list fetching #361

Merged
merged 4 commits into from Mar 15, 2022
Merged

adds test for token list fetching #361

merged 4 commits into from Mar 15, 2022

Conversation

schmanu
Copy link
Collaborator

@schmanu schmanu commented Feb 11, 2022

Just a small test case which would have found the error while fetching / parsing the token list.

Copy link
Owner

@bh2smith bh2smith left a comment

Choose a reason for hiding this comment

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

Looks good. Love tests. One suggestion to remove lint ignores.

Comment on lines 54 to 56
const resultingTokens = await fetchTokenList(1);
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
expect(resultingTokens).to.be.empty;
Copy link
Owner

Choose a reason for hiding this comment

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

Could you avoid the lint ignore by putting the await statement directly into the expect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem here is that the to.be.empty is not a function so it looks like a normal expression which is not used.
But in fact this actually does something (checking if the object ist empty). There are other tests with the same issue.

I found a more elegant solution which disabled this rule for all test files by including this in the eslint config:

{
    "overrides": [
        {
            "files": ["*.test.ts", "*.test.tsx"],
            "rules": {
                "no-unused-expressions": "off"
            }
        }
    ]
}

Copy link
Owner

Choose a reason for hiding this comment

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

Seems legit... go for it!

We use chai for testing and the empty check is always a false positive finding.
@bh2smith
Copy link
Owner

bh2smith commented Mar 4, 2022

Looks ready!

@schmanu schmanu merged commit f8e1892 into master Mar 15, 2022
@schmanu schmanu deleted the test-for-tokenlist branch March 15, 2022 13:46
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.

None yet

2 participants