From b2c2ef2bd66230fdc39103293320983e73b32e90 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Wed, 28 Sep 2022 15:25:16 +0200 Subject: [PATCH] Test querySelectorAll call --- test/theme-test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/theme-test.ts b/test/theme-test.ts index 47e42f5a70..8e0e6c94e1 100644 --- a/test/theme-test.ts +++ b/test/theme-test.ts @@ -21,6 +21,8 @@ describe('theme', () => { let lightTheme; let darkTheme; + let spyQuerySelectorAll: jest.MockInstance, [selectors: string]>; + beforeEach(() => { const styles = [ { @@ -48,7 +50,7 @@ describe('theme', () => { darkTheme = styles[1]; jest.spyOn(document.body, 'style', 'get').mockReturnValue([] as any); - jest.spyOn(document, 'querySelectorAll').mockReturnValue(styles as any); + spyQuerySelectorAll = jest.spyOn(document, 'querySelectorAll').mockReturnValue(styles as any); }); afterEach(() => { @@ -64,6 +66,8 @@ describe('theme', () => { }); // Then + expect(spyQuerySelectorAll).toHaveBeenCalledWith('[data-mx-theme]'); + expect(spyQuerySelectorAll).toBeCalledTimes(1); expect(lightTheme.disabled).toBe(false); expect(darkTheme.disabled).toBe(true); });