refactor: switch from jsdom to happy-dom
This commit is contained in:
@@ -1,29 +1,13 @@
|
||||
import type { Provider } from '@outposts/injection-js';
|
||||
import { JSDOM } from 'jsdom';
|
||||
import { AbstractRouter, type Navigation, type UrlTree } from 'oidc-client-rx';
|
||||
import {
|
||||
AbstractRouter,
|
||||
type UrlTree,
|
||||
VanillaLocationRouter,
|
||||
} from 'oidc-client-rx';
|
||||
|
||||
export class MockRouter extends AbstractRouter {
|
||||
dom = new JSDOM('', {
|
||||
url: 'http://localhost',
|
||||
});
|
||||
|
||||
navigation: Navigation = {
|
||||
extractedUrl: this.parseUrl(this.dom.window.location.href),
|
||||
};
|
||||
|
||||
navigateByUrl(url: string): void {
|
||||
this.dom.reconfigure({
|
||||
url: new URL(url, this.dom.window.location.href).href,
|
||||
});
|
||||
this.navigation = {
|
||||
extractedUrl: this.parseUrl(this.dom.window.location.href),
|
||||
};
|
||||
}
|
||||
getCurrentNavigation(): Navigation {
|
||||
return this.navigation;
|
||||
}
|
||||
export class MockRouter extends VanillaLocationRouter {
|
||||
parseUrl(url: string): UrlTree {
|
||||
const u = new URL(url, this.dom.window.location.href);
|
||||
const u = new URL(url, this.document.baseURI);
|
||||
return `${u.pathname}${u.search}${u.hash}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user