wire-service-jest-util icon indicating copy to clipboard operation
wire-service-jest-util copied to clipboard

feat: provide reset last config method

Open rochejul opened this issue 2 years ago • 3 comments

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

rochejul avatar Feb 21 '23 08:02 rochejul

@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 avatar Jun 27 '23 12:06 rochejul

@rochejul The LWC team (my team) owns this.

nolanlawson avatar Jun 27 '23 15:06 nolanlawson

Many thanks

rochejul avatar Jun 27 '23 15:06 rochejul