From 2314e82341c21df99aee74779cf0abb626a84e16 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Fri, 19 Feb 2021 18:16:55 +0100 Subject: [PATCH] more return information --- src/usecases/hello.test.ts | 2 +- src/usecases/hello.ts | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/usecases/hello.test.ts b/src/usecases/hello.test.ts index f1ae587..2dfc985 100644 --- a/src/usecases/hello.test.ts +++ b/src/usecases/hello.test.ts @@ -5,7 +5,7 @@ import { sayHello, sayRandomHello } from "./hello.ts"; Deno.test("Random Hello", () => { const result = sayRandomHello(); const actual = typeof result; - const expected = "string"; + const expected = "object"; assertStrictEquals(actual, expected); }); diff --git a/src/usecases/hello.ts b/src/usecases/hello.ts index 5e99b22..266db5d 100644 --- a/src/usecases/hello.ts +++ b/src/usecases/hello.ts @@ -1,6 +1,12 @@ import { getLocaleById, localesSize } from "../repositories/locales.ts"; import { ID } from "../types/id.ts"; +type HelloResponse = { + id: number; + locale: string; + message: string; +}; + /** * Display the iconic Hello, World in a random locale */ @@ -14,6 +20,10 @@ export const sayRandomHello = () => { * Display the iconic Hello, World in a locale identified by id * @param id Unique identifier */ -export const sayHello = (id: ID): string => { - return getLocaleById(id.value); +export const sayHello = (id: ID): HelloResponse => { + return { + id: id.value, + locale: "", + message: getLocaleById(id.value), + }; };