@furystack/shades
Version:
Google Authentication Provider for FuryStack
33 lines • 1.54 kB
JavaScript
import { TextDecoder, TextEncoder } from 'util';
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
import { Injector } from '@furystack/inject';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { initializeShadeRoot } from '../initialize.js';
import { LocationService } from '../services/location-service.js';
import { createComponent } from '../shade-component.js';
import { RouteLink } from './route-link.js';
describe('RouteLink', () => {
beforeEach(() => {
document.body.innerHTML = '<div id="root"></div>';
});
afterEach(() => {
document.body.innerHTML = '';
});
it('Shuld display the loader and completed state', async () => {
const injector = new Injector();
const rootElement = document.getElementById('root');
const onRouteChange = vi.fn();
injector.getInstance(LocationService).onLocationPathChanged.subscribe(onRouteChange);
initializeShadeRoot({
injector,
rootElement,
jsxElement: (createComponent(RouteLink, { id: "route", href: "/subroute" }, "Link")),
});
expect(document.body.innerHTML).toMatchInlineSnapshot(`"<div id="root"><a is="route-link" id="route" href="/subroute" style="color: inherit; text-decoration: inherit;">Link</a></div>"`);
expect(onRouteChange).not.toBeCalled();
document.getElementById('route')?.click();
expect(onRouteChange).toBeCalledTimes(1);
});
});
//# sourceMappingURL=route-link.spec.js.map