Skip to content

Commit d11f0df

Browse files
committed
register test
1 parent 3e91a23 commit d11f0df

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/javascripts/register-security-key.test.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import ErrorBanner from '../../app/assets/javascripts/esm/error-banner.mjs';
33
import { jest } from '@jest/globals';
44
import * as helpers from './support/helpers';
55

6-
jest.mock('../../app/assets/javascripts/esm/error-banner.mjs');
7-
86
beforeAll( async() => {
97
const CBOR = await import('../../node_modules/cbor-js/cbor.js');
108
window.CBOR = CBOR.default || CBOR;
@@ -18,6 +16,7 @@ describe('Register security key', () => {
1816
let mockFetch;
1917
let mockWebauthnOptions;
2018
let registerKeyInstance;
19+
let errorBannerShowBannerSpy;
2120

2221
const mockBrowserCredentials = {
2322
create: jest.fn(),
@@ -54,6 +53,10 @@ describe('Register security key', () => {
5453
// create a mock event for the click handler
5554
mockClickEvent = { preventDefault: jest.fn() };
5655

56+
// spy on the showBanner method of ErroBanner class
57+
// and mock its implementation, allowing us to assert whether it was called
58+
errorBannerShowBannerSpy = jest.spyOn(ErrorBanner.prototype, 'showBanner').mockImplementation(() => {});
59+
5760
// mock the window fetch function
5861
mockFetch = jest.fn();
5962
window.fetch = mockFetch;

0 commit comments

Comments
 (0)