Skip to content

Commit 469100d

Browse files
committed
cpde raaddit resolve
1 parent 69d2b6b commit 469100d

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx

+31-27
Original file line numberDiff line numberDiff line change
@@ -402,35 +402,39 @@ describe('Testing AddOnStore Component', () => {
402402

403403
expect(dropdownToggle.textContent).toBe('Enabled');
404404
});
405+
405406
// Add this test to AddOnStore.spec.tsx
406407
test('properly marks plugins as installed or not installed based on their IDs', async () => {
407-
// Mock the PluginHelper implementation
408-
vi.mock('components/AddOn/support/services/Plugin.helper', () => ({
409-
__esModule: true,
410-
default: vi.fn().mockImplementation(() => ({
411-
fetchStore: vi.fn().mockResolvedValue([
412-
{
413-
id: '1', // This ID matches one in the installed plugins
414-
pluginName: 'Plugin 1',
415-
pluginDesc: 'Description 1',
416-
pluginCreatedBy: 'User 1',
417-
},
418-
{
419-
id: '2', // This ID doesn't match any installed plugin
420-
pluginName: 'Plugin 2',
421-
pluginDesc: 'Description 2',
422-
pluginCreatedBy: 'User 2',
423-
},
424-
]),
425-
fetchInstalled: vi.fn().mockResolvedValue([
426-
{
427-
id: '1', // This ID matches one of the store plugins
428-
pluginName: 'Installed Plugin 1',
429-
pluginDesc: 'Installed Description 1',
430-
pluginCreatedBy: 'User 3',
431-
},
432-
]),
433-
})),
408+
// Reset and configure mocks for this specific test
409+
vi.resetAllMocks();
410+
const mockFetchStore = vi.fn().mockResolvedValue([
411+
{
412+
id: '1', // This ID matches one in the installed plugins
413+
pluginName: 'Plugin 1',
414+
pluginDesc: 'Description 1',
415+
pluginCreatedBy: 'User 1',
416+
},
417+
{
418+
id: '2', // This ID doesn't match any installed plugin
419+
pluginName: 'Plugin 2',
420+
pluginDesc: 'Description 2',
421+
pluginCreatedBy: 'User 2',
422+
},
423+
]);
424+
const mockFetchInstalled = vi.fn().mockResolvedValue([
425+
{
426+
id: '1', // This ID matches one of the store plugins
427+
pluginName: 'Installed Plugin 1',
428+
pluginDesc: 'Installed Description 1',
429+
pluginCreatedBy: 'User 3',
430+
},
431+
]);
432+
433+
// Configure the mock implementation for this test
434+
vi.mocked(PluginHelper).mockImplementation(() => ({
435+
fetchStore: mockFetchStore,
436+
fetchInstalled: mockFetchInstalled,
437+
generateLinks: vi.fn(),
434438
}));
435439

436440
// Create a spy on the store dispatch

0 commit comments

Comments
 (0)