debian-mirror-gitlab/spec/frontend/authentication/webauthn/util.js

20 lines
542 B
JavaScript
Raw Normal View History

2020-11-24 15:15:51 +05:30
export function useMockNavigatorCredentials() {
let oldNavigatorCredentials;
let oldPublicKeyCredential;
beforeEach(() => {
oldNavigatorCredentials = navigator.credentials;
oldPublicKeyCredential = window.PublicKeyCredential;
navigator.credentials = {
get: jest.fn(),
create: jest.fn(),
};
window.PublicKeyCredential = function MockPublicKeyCredential() {};
});
afterEach(() => {
navigator.credentials = oldNavigatorCredentials;
window.PublicKeyCredential = oldPublicKeyCredential;
});
}