Skip to content

Commit

Permalink
Merge pull request #6 from elmerbulthuis/renaming-operation-handler
Browse files Browse the repository at this point in the history
fix operation handler name
  • Loading branch information
IsraelOjiefoh authored Aug 12, 2024
2 parents 95af824 + bec4801 commit 41cfa9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions packages/npm/todo/src/operation-handlers/todo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import * as api from "todo-api";
import * as addTodoOperationHandler from "./todo.js";

test("create todo", async (t) => {
const server = new api.server.Server();
server.registerAddTodoItemOperation(addTodoOperationHandler.addTodoOperationHandler);
await using listener = await api.lib.listen(server);
const baseUrl = new URL(`http://localhost:${listener.port}`);
const server = new api.server.Server();
server.registerAddTodoItemOperation(addTodoOperationHandler.addTodoItem);
await using listener = await api.lib.listen(server);
const baseUrl = new URL(`http://localhost:${listener.port}`);

const result = await api.client.addTodoItem({"description":"Wash clothes"}, { baseUrl });
const result = await api.client.addTodoItem({ description: "Wash clothes" }, { baseUrl });

// Log the result to see what's returned
console.log("Returned result:", result);
// Log the result to see what's returned
console.log("Returned result:", result);

// Check if the result matches the expected format
assert.equal(result.description, "Wash clothes");
assert.equal(result.done, false);
assert.equal(typeof result.id, "number");


// Check if the result matches the expected format
assert.equal(result.description, "Wash clothes");
assert.equal(result.done, false);
assert.equal(typeof result.id, "number");
});
2 changes: 1 addition & 1 deletion packages/npm/todo/src/operation-handlers/todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as api from "todo-api";
import { CommandHandlers } from "../commandHandlers/commandHandlers.js";
import CreateTodo from "../commands/createTodo.js";

export const addTodoOperationHandler: api.server.AddTodoItemOperationHandler<{}> = async (todo) => {
export const addTodoItem: api.server.AddTodoItemOperationHandler<{}> = async (todo) => {
const createTodoCommand = new CreateTodo(todo.description);
const commandHandlers = new CommandHandlers();

Expand Down

0 comments on commit 41cfa9d

Please sign in to comment.