wire-service-jest-util
wire-service-jest-util copied to clipboard
feat: provide reset last config method
Related to issue #71 , this PR contains the ability for each adapter to have a resetLastConfig
method.
This pr contains:
- Add on the base adapter the method
- Add tests for each adapters
- Refactor the adapters' inheritance
I needed to revisit the adapters' inheritance because for some inheritance troubles, the last Apex use case fails when we test the getLastConfig
:
const cases = [
// Works
{
testName: 'new api (via createApexTestWireAdapter)',
adapter: ApexMethod,
adapterName: 'ApexMethod',
},
// Works
{
testName: 'legacy api (registerApexTestWireAdapter) used with legacy adapter mock',
adapter: registerApexTestWireAdapter(LegacyApexMethod),
adapterName: 'LegacyApexMethod',
},
// Fails
{
testName: 'legacy api (registerApexTestWireAdapter) used with new adapter mock',
adapter: registerApexTestWireAdapter(ApexMethod),
adapterName: 'ApexMethod',
},
];
I have the feeling the case n°2 mutate the adapter and then when we call the restLastConfig
on it, the next calls of getLastConfig
will fail.
With the refactoring, everything works now
@nolanlawson sorry to ping you: do you know which team should I at-mention to review this PR please?
Many thanks for your help
@rochejul The LWC team (my team) owns this.
Many thanks