I have this in an LWC:
import {getObjectInfo} from 'lightning/uiObjectInfoApi';
@wire(getObjectInfo, { objectApiName: 'My_First_Object__c' })
receiveMyFirstInfo({error, data}) {
if (data) {
// do something
} else if (error) {
// handle error
}
};
@wire(getObjectInfo, { objectApiName: 'My_Second_Object__c' })
receiveMySecondInfo({error, data}) {
if (data) {
// do something
} else if (error) {
// handle error
}
};
I have this in a jest test:
import {createTestWireAdapter} from '@salesforce/sfdx-lwc-jest';
const getObjectInfoWireAdapter = createTestWireAdapter();
getObjectInfoWireAdapter.emit({ myFirstProperty: 'my first value' },
config => config.objectApiName === 'My_First_Object__c');
getObjectInfoWireAdapter.emit({ mySecondProperty: 'my second value' },
config => config.objectApiName === 'My_Second_Object__c');
From examples and docs, this should work.
It does work when there is only one wire and one emit and no config params.
When there are two wires and one emit and the config param explicitly returns true, the emit fires both wires.
Anytime there is a config param for the emit, the config param is always an empty object, so I cannot test any property that should be in there, so cannot differentiate between the two wires.
How can I make these two wires receive data only from the appropriate emits?