Skip to content

Conversation

@matt-gadd
Copy link
Contributor

@matt-gadd matt-gadd commented Apr 8, 2019

Type: feature

The following has been addressed in the PR:

Description:
TODO: Fill this out explaining enhancements.

API's changed:

replace -> replaceChildren

(this #247 (comment) came back to haunt me)

API's added:

replace
remove
setProperties
getProperties

New Assertion Template primitive:

Ignore

@aciccarello
Copy link
Contributor

@matt-gadd matt-gadd added area: testing Testing breaking change Indicates the issue/pull request would result in a breaking change enhancement New feature or request labels Apr 8, 2019
Copy link
Contributor

@aciccarello aciccarello left a comment

Choose a reason for hiding this comment

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

Looking forward to this change.I know this is a WIP PR but I wanted to leave a couple notes on things I noticed when checking this out.

The CLI will need to have a codemod to rename the old replace function as well.

const parent = (node as any).parent;
const children = [...parent.children];
children.splice(children.indexOf(node), 1);
parent.children = [node, ...children];
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this always put the replacement node at the beginning of the children? You should be able to pass the replacement with .splice().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks was being silly here from the copy pasta from remove

const parsedExpected = formatDNodes(expected);
const [decoratedActual, decoratedExpected] = decorate(actual, expected);
const parsedActual = formatDNodes(Array.isArray(actual) ? decoratedActual : decoratedActual[0]);
const parsedExpected = formatDNodes(Array.isArray(expected) ? decoratedExpected : decoratedExpected[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain what is going on with the isArray check? Shouldn't this be changed to the following?

Suggested change
const parsedExpected = formatDNodes(Array.isArray(expected) ? decoratedExpected : decoratedExpected[0]);
const parsedExpected = formatDNodes(Array.isArray(decoratedExpected) ? decoratedExpected[0] : decoratedExpected);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aciccarello the decorator function always turns nodes into an array (if it isn't already) and returns an array. the assertRender function and formatDNodes take an individual node or an array. so all this does is use the first node if the original nodes (expected and actual) were a singular node. So no the suggested change is incorrect. I might change the decorate function to align with formatDNodes to avoid this slightly confusing conversion though.

let expectedNode = expected[i];

if (isWNode(expectedNode)) {
[actualNode, expectedNode] = assertionWidgets.reduce(
Copy link
Contributor

Choose a reason for hiding this comment

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

this part is somewhat confusing to me. I can follow what it is doing, but it isn't clear to me why it i doing what it is doing. If you are changing the actualNode and expectedNode references, does it really make sense to use reduce here? I think a forEach might end up being simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, i just removed the loop completely in the end as the indirection wasn't worth it.

@matt-gadd matt-gadd force-pushed the assertion-template-enhancements branch from a40e640 to b9a3bcc Compare May 3, 2019 13:09
@matt-gadd matt-gadd changed the title WIP: Assertion Template Enhancements Assertion Template Enhancements May 3, 2019
@aciccarello
Copy link
Contributor

@matt-gadd is there anything I can do to help with this?

@agubler agubler mentioned this pull request Jun 25, 2019
2 tasks
@agubler
Copy link
Member

agubler commented Jun 25, 2019

superseded by #412

@agubler agubler closed this Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: testing Testing breaking change Indicates the issue/pull request would result in a breaking change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants