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.
35 lines (29 loc) • 935 B
text/typescript
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);
});
});