Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/core/src/__tests__/StorageStrategy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('SessionStorageStrategy', () => {
// @ts-expect-error - Testing undefined sessionStorage
delete global.sessionStorage;

const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
using consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined);

const strategy = new SessionStorageStrategy();

Expand All @@ -139,7 +139,6 @@ describe('SessionStorageStrategy', () => {
expect(() => strategy.removeItem('test')).not.toThrow();
expect(() => strategy.clear()).not.toThrow();

consoleSpy.mockRestore();
global.sessionStorage = originalSessionStorage;
});
});
Expand Down
16 changes: 4 additions & 12 deletions packages/core/src/__tests__/Users.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('YouVersionAPIUsers', () => {
);

// Mock YouVersionPlatformConfiguration.saveAuthData
const saveAuthDataSpy = vi.spyOn(YouVersionPlatformConfiguration, 'saveAuthData');
using saveAuthDataSpy = vi.spyOn(YouVersionPlatformConfiguration, 'saveAuthData');

const result = await YouVersionAPIUsers.handleAuthCallback();

Expand All @@ -217,8 +217,6 @@ describe('YouVersionAPIUsers', () => {
'',
'https://example.com/callback',
);

saveAuthDataSpy.mockRestore();
});

it('should handle token exchange failure', async () => {
Expand Down Expand Up @@ -395,13 +393,11 @@ describe('YouVersionAPIUsers', () => {

describe('signOut', () => {
it('should call setAccessToken with null', () => {
const setAccessTokenSpy = vi.spyOn(YouVersionPlatformConfiguration, 'clearAuthTokens');
using setAccessTokenSpy = vi.spyOn(YouVersionPlatformConfiguration, 'clearAuthTokens');

YouVersionAPIUsers.signOut();

expect(setAccessTokenSpy).toHaveBeenCalled();

setAccessTokenSpy.mockRestore();
});
});

Expand Down Expand Up @@ -527,7 +523,7 @@ describe('YouVersionAPIUsers', () => {

mockFetch.mockResolvedValue(mockResponse);

const saveAuthDataSpy = vi.spyOn(YouVersionPlatformConfiguration, 'saveAuthData');
using saveAuthDataSpy = vi.spyOn(YouVersionPlatformConfiguration, 'saveAuthData');

const result = await YouVersionAPIUsers.refreshTokens();

Expand Down Expand Up @@ -567,8 +563,6 @@ describe('YouVersionAPIUsers', () => {
existingIdToken,
expect.any(Date),
);

saveAuthDataSpy.mockRestore();
});

it('should handle refresh token request failure', async () => {
Expand Down Expand Up @@ -707,14 +701,12 @@ describe('YouVersionAPIUsers', () => {
statusText: 'Unauthorized',
});

const clearAuthTokensSpy = vi.spyOn(YouVersionPlatformConfiguration, 'clearAuthTokens');
using clearAuthTokensSpy = vi.spyOn(YouVersionPlatformConfiguration, 'clearAuthTokens');

const result = await YouVersionAPIUsers.refreshTokenIfNeeded();

expect(result).toBe(false);
expect(clearAuthTokensSpy).toHaveBeenCalled();

clearAuthTokensSpy.mockRestore();
});
});
});
3 changes: 1 addition & 2 deletions packages/core/src/__tests__/languages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ describe('LanguagesClient', () => {
});

it('should normalize lowercase country codes to uppercase', async () => {
const getSpy = vi.spyOn(apiClient, 'get');
using getSpy = vi.spyOn(apiClient, 'get');

await languagesClient.getLanguages({ country: 'us', page_size: 5 });

expect(getSpy).toHaveBeenCalledWith(
'/v1/languages',
expect.objectContaining({ country: 'US' }),
);
getSpy.mockRestore();
});

it('should fetch languages with valid fields filter', async () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/ui/src/components/bible-version-picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('BibleVersionPicker', () => {
abbreviation: 'NIV',
},
];
const getItemSpy = vi.spyOn(Storage.prototype, 'getItem').mockImplementation((key) => {
using _getItemSpy = vi.spyOn(Storage.prototype, 'getItem').mockImplementation((key) => {
if (key === RECENT_VERSIONS_KEY) return JSON.stringify(recentVersions);
return null;
});
Expand All @@ -175,8 +175,6 @@ describe('BibleVersionPicker', () => {
});

expect(screen.queryByText('No versions found')).toBeNull();

getItemSpy.mockRestore();
});

it('should show spinner in badge when versions are loading', async () => {
Expand Down
Loading