Files
advanced-camera-card/tests/card-controller/actions/actions/url.test.ts
T
Dermot Duffy 75ae7720d3 fix: Confirmations should apply to all actions (#1959)
This also refactors how generic HA actions are handled, and improves
typing of actions.


[skip ci]
2025-03-15 14:32:48 -07:00

26 lines
714 B
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest';
import { URLAction } from '../../../../src/card-controller/actions/actions/url';
import { createCardAPI } from '../../../test-utils';
// @vitest-environment jsdom
describe('URLAction', () => {
afterEach(() => {
vi.restoreAllMocks();
});
it('should open the URL in a new window', async () => {
const urlAction = new URLAction(
{},
{
action: 'url',
url_path: 'https://example.com',
},
);
const windowOpenSpy = vi.spyOn(window, 'open').mockImplementation(() => null);
await urlAction.execute(createCardAPI());
expect(windowOpenSpy).toHaveBeenCalledWith('https://example.com');
});
});