UNPKG

dt-app

Version:

The Dynatrace App Toolkit is a tool you can use from your command line to create, develop, and deploy apps on your Dynatrace environment.

39 lines (32 loc) 1.01 kB
/** * @jest-environment @dynatrace/runtime-simulator/lib/test-environment */ import actionName from './action-name.action'; import { buildMockedFetchResponse } from './test-utils'; describe('action-name', () => { let fetchMock; beforeEach(() => { fetchMock = jest.fn(); globalThis.fetch = fetchMock; }); afterEach(() => { // Clean up the mock to prevent interference with other tests fetchMock.mockClear(); }); it('should produce expected results', async () => { fetchMock.mockImplementation(() => buildMockedFetchResponse({ schemaId: 'action-name-connection', value: { name: 'My Connection', token: 'abc123', url: 'https://foo.bar', }, summary: 'My Connection', }), ); const result = await actionName({ name: 'Mark', connectionId: 'action-name-connection-object-id' }); expect(result).toEqual({ message: 'Hello Mark!' }); expect.assertions(1); }); });