Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

chore(infrastructure): Better error messages in verifyDefaultAdapter #3516

Merged
merged 12 commits into from
Sep 7, 2018

Conversation

acdvorak
Copy link
Contributor

@acdvorak acdvorak commented Sep 5, 2018

This PR adds more helpful error messages when adapters don't match the expected method names.

Before:

expected [ Array(21) ] to deeply equal [ Array(21) ]

After:

Found 1 unexpected method: addClass; 1 missing method: addClassX

image

@codecov-io
Copy link

codecov-io commented Sep 5, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@3d285d9). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #3516   +/-   ##
=========================================
  Coverage          ?   98.41%           
=========================================
  Files             ?      120           
  Lines             ?     5033           
  Branches          ?      619           
=========================================
  Hits              ?     4953           
  Misses            ?       80           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d285d9...8ee2b82. Read the comment docs.

@acdvorak acdvorak changed the title chore(infrastructure): Allow adapters to be class instances chore(infrastructure): Better error messages in verifyDefaultAdapter Sep 5, 2018
const expectedSet = toSet(expectedArray);
const addedStr = getAddedStr(actualSet, expectedSet);
const removedStr = getRemovedStr(actualSet, expectedSet);
const messages = [addedStr, removedStr].filter((val) => Boolean(val));
Copy link
Contributor

Choose a reason for hiding this comment

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

(val) => val.length > 0 ? Makes it a little more clear this is just filtering out empty strings...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

export function setupFoundationTest(FoundationClass) {
// Make code coverage happy by instantiating the class with no arguments.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused... where were we missing coverage due to this? Judging by this comment it should currently be impossible for us to have 100% branch coverage on foundations, but that's clearly not the case...

Copy link
Contributor Author

@acdvorak acdvorak Sep 5, 2018

Choose a reason for hiding this comment

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

All I know is that Dialog code coverage was stuck at 13/14 branches until I added this line. 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this line:

image

File   Statements   Branches   Functions   Lines  
constants.js   100% 3/3 100% 0/0 100% 0/0 100% 3/3
foundation.js   100% 64/64 92.86% 13/14 100% 22/22 100% 61/61
index.js   100% 46/46 100% 6/6 100% 31/31 100% 45/45
util.js   100% 6/6 100% 2/2 100% 4/4 100% 5/5

With this line:

image

File   Statements   Branches   Functions   Lines  
constants.js   100% 3/3 100% 0/0 100% 0/0 100% 3/3
foundation.js   100% 64/64 100% 14/14 100% 22/22 100% 61/61
index.js   100% 46/46 100% 6/6 100% 31/31 100% 45/45
util.js   100% 6/6 100% 2/2 100% 4/4 100% 5/5

Copy link
Contributor

Choose a reason for hiding this comment

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

I just ran coverage with/without this line and it only affects branch coverage in dialog, line-ripple, and list. I'll see if I can figure out why, but I am inclined to leave it out of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I figured out why 3 specific components have diffs with this line. It's because for some reason those components are using a default parameter in their foundation constructors, whereas all other foundations use an Object.assign within the constructor instead. I'm not sure what prompted this deviation, as the Object.assign pattern existed much earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#3522 removes the default parameters from line-ripple and list.

@kfranqueiro kfranqueiro merged commit 92fd9a7 into master Sep 7, 2018
@kfranqueiro kfranqueiro deleted the chore/infra/adapter-class branch September 7, 2018 15:38
adrianschmidt pushed a commit to Lundalogik/material-components-web that referenced this pull request Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants