Skip to content

Commit

Permalink
test: improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ahochsteger committed Apr 21, 2024
1 parent 8b24e87 commit 1545e87
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
11 changes: 1 addition & 10 deletions src/lib/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,7 @@ export class ProcessingResult {
}

export function newProcessingResult(): ProcessingResult {
return {
executedActions: [],
processedAttachmentConfigs: 0,
processedAttachments: 0,
processedMessageConfigs: 0,
processedMessages: 0,
processedThreadConfigs: 0,
processedThreads: 0,
status: ProcessingStatus.OK,
}
return new ProcessingResult()
}

export type Context =
Expand Down
38 changes: 38 additions & 0 deletions src/lib/e2e/E2E.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mock } from "jest-mock-extended"
import { ExampleInfo } from "../../examples/Example"
import { ConfigMocks } from "../../test/mocks/ConfigMocks"
import { MockFactory, Mocks } from "../../test/mocks/MockFactory"
import {
EnvContext,
Expand Down Expand Up @@ -389,3 +390,40 @@ describe("runTests", () => {
expect((result.error as Error)?.message).toContain("A forced exeption")
})
})

describe("runTests with migrationConfig", () => {
let globals: E2EGlobalConfig
let mockTestConfig: E2ETestConfig
let migrationConfig
beforeAll(() => {
globals = newE2EGlobalConfig(ctx)
const info: ExampleInfo = {
name: "test-v1",
title: "Test v1 config",
description: "Test v1 config description",
category: "basics",
schemaVersion: "v1",
}
const initConfig: E2EInitConfig = {
mails: [{}],
}
migrationConfig = ConfigMocks.newDefaultV1ConfigJson()
const mockTests: E2ETest[] = []
mockTestConfig = {
info,
globals,
initConfig,
migrationConfig,
tests: mockTests,
} as E2ETestConfig
})

beforeEach(() => {
jest.clearAllMocks()
})
it("should process migrationConfig", () => {
E2E.runTests(mockTestConfig, true, undefined, RunMode.DANGEROUS, ctx)

expect(ctx.env.mailApp.sendEmail).not.toHaveBeenCalled()
})
})

0 comments on commit 1545e87

Please sign in to comment.