parse5 icon indicating copy to clipboard operation
parse5 copied to clipboard

Update location info test to conform to newly constrained location type

Open 43081j opened this issue 2 years ago • 1 comments

https://github.com/inikulin/parse5/blob/f5dd91e2dd846ec5cfeda425c652ce47dffb0539/packages/parse5/lib/parser/parser-location-info.test.ts#L235-L290

This test currently creates its own location structure and asserts that it ends up in the resulting node.

It currently passes because of its parameters being any. However, if we strongly type those, the test fails to compile.

This is because during the TS conversion, we introduced a new constraint: all locations must be a Location (i.e. you can no longer create your own location structure, but could before).

We should probably just update this test to follow the Location type. Though maybe put something in it to identify it actually called our test callback rather than the default (since both would produce the same result at that point...)

This is basically a prerequisite of enforcing the no-explicit-any lint rule.

cc @fb55

43081j avatar Mar 14 '22 19:03 43081j

We should probably just update this test to follow the Location type. Though maybe put something in it to identify it actually called our test callback rather than the default (since both would produce the same result at that point...)

This makes sense to me. The best option I can come up with is to create a class that implements Location, and then do instanceof checks in the assertions.

fb55 avatar Mar 16 '22 11:03 fb55