petitpandarouge / ObsidianScripts

🎈 Inflates your Obsidian.
MIT License
2 stars 0 forks source link

Implement dependency injection for the Obsidian Notice class. #19

Closed petitpandarouge closed 1 month ago

petitpandarouge commented 1 month ago

This is a way of having cleaner testable code and remove these peaces of codes that hardly mean something.

jest.mock('obsidian', () => {
    return {
        Notice: jest.fn()
    };
});
...
const mockNotice = jest.fn();
(Notice as jest.Mock) = mockNotice;

This enhancement imply struturing the whole entry points plugins to be compatible with injection dependency.