Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
leonitousconforti committed Sep 25, 2024
1 parent 3462af4 commit 4fd9392
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
52 changes: 31 additions & 21 deletions packages/vitest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import type * as Duration from "effect/Duration"
import type * as Effect from "effect/Effect"
import type * as ManagedRuntime from "effect/ManagedRuntime"
import type * as Scope from "effect/Scope"
import type * as TestServices from "effect/TestServices"
import * as V from "vitest"
Expand Down Expand Up @@ -48,30 +49,11 @@ export namespace Vitest {
) => <A, E>(name: string, self: TestFunction<A, E, R, Array<T>>, timeout?: number | V.TestOptions) => void
}
}
/**
* @since 1.0.0
*/
export const addEqualityTesters: () => void = internal.addEqualityTesters

/**
* @since 1.0.0
*/
export const effect: Vitest.Tester<TestServices.TestServices> = internal.effect

/**
* @since 1.0.0
*/
export const scoped: Vitest.Tester<TestServices.TestServices | Scope.Scope> = internal.scoped

/**
* @since 1.0.0
*/
export const live: Vitest.Tester<never> = internal.live

/**
* @since 1.0.0
*/
export const scopedLive: Vitest.Tester<Scope.Scope> = internal.scopedLive
export const addEqualityTesters: () => void = internal.addEqualityTesters

/**
* @since 1.1.0
Expand Down Expand Up @@ -109,6 +91,33 @@ export const afterEachEffect: <E>(
) => Effect.Effect<void | PromiseLike<void>, E, never>
) => void = internal.afterEach

/**
* @since 1.0.0
*/
export const effect: Vitest.Tester<TestServices.TestServices> = internal.effect

/**
* @since 1.0.0
*/
export const scoped: Vitest.Tester<TestServices.TestServices | Scope.Scope> = internal.scoped

/**
* @since 1.0.0
*/
export const live: Vitest.Tester<never> = internal.live

/**
* @since 1.0.0
*/
export const scopedLive: Vitest.Tester<Scope.Scope> = internal.scopedLive

/**
* @since 1.1.0
*/
export const withManagedRuntime: <R, ER>(
managedRuntime: ManagedRuntime.ManagedRuntime<R, ER>
) => Vitest.Tester<R> = internal.withManagedRuntime

/**
* @since 1.0.0
*/
Expand All @@ -127,7 +136,8 @@ const methods = {
beforeAllEffect,
beforeEachEffect,
afterAllEffect,
afterEachEffect
afterEachEffect,
withManagedRuntime
} as const

/**
Expand Down
9 changes: 9 additions & 0 deletions packages/vitest/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { expect, it } from "@effect/vitest"
import { Effect } from "effect"

// hooks

it.beforeAllEffect(() => Effect.void)
it.beforeEachEffect(() => Effect.void)
it.afterEachEffect(() => Effect.void)
it.afterAllEffect(() => Effect.void)

// effects

it.live(
"live %s",
() => Effect.sync(() => expect(1).toEqual(1))
Expand Down

0 comments on commit 4fd9392

Please sign in to comment.