Tests
This commit is contained in:
@@ -83,4 +83,14 @@ export const createDefaultTodos = Effect.gen(function*() {
|
|||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
yield* todos.add(new Todo({
|
||||||
|
id: Option.none(),
|
||||||
|
title: "Another one",
|
||||||
|
content: "Lorem ipsum",
|
||||||
|
due: Option.none(),
|
||||||
|
completed: false,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BunRuntime } from "@effect/platform-bun"
|
import { BunRuntime } from "@effect/platform-bun"
|
||||||
import { Effect } from "effect"
|
import { Todo } from "@todo-tests/common/data"
|
||||||
|
import { Array, Effect } from "effect"
|
||||||
import { TodoRepository, TodoRepositoryLive, createDefaultTodos } from "./TodoRepository"
|
import { TodoRepository, TodoRepositoryLive, createDefaultTodos } from "./TodoRepository"
|
||||||
|
|
||||||
|
|
||||||
@@ -8,6 +9,17 @@ const main = Effect.gen(function*() {
|
|||||||
|
|
||||||
const todos = yield* TodoRepository
|
const todos = yield* TodoRepository
|
||||||
console.log(yield* todos.todos.get)
|
console.log(yield* todos.todos.get)
|
||||||
|
|
||||||
|
const secondTodo = yield* yield* todos.todos.get.pipe(
|
||||||
|
Effect.map(Array.get(1))
|
||||||
|
)
|
||||||
|
const secondTodoModified = new Todo({
|
||||||
|
...secondTodo,
|
||||||
|
completed: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
yield* todos.update(secondTodoModified)
|
||||||
|
console.log(yield* todos.todos.get)
|
||||||
})
|
})
|
||||||
|
|
||||||
const runnableMain = main.pipe(
|
const runnableMain = main.pipe(
|
||||||
|
|||||||
Reference in New Issue
Block a user