more return information

This commit is contained in:
Ruidy 2021-02-19 18:16:55 +01:00
parent 97506731e1
commit 2314e82341
2 changed files with 13 additions and 3 deletions

View file

@ -5,7 +5,7 @@ import { sayHello, sayRandomHello } from "./hello.ts";
Deno.test("Random Hello", () => { Deno.test("Random Hello", () => {
const result = sayRandomHello(); const result = sayRandomHello();
const actual = typeof result; const actual = typeof result;
const expected = "string"; const expected = "object";
assertStrictEquals(actual, expected); assertStrictEquals(actual, expected);
}); });

View file

@ -1,6 +1,12 @@
import { getLocaleById, localesSize } from "../repositories/locales.ts"; import { getLocaleById, localesSize } from "../repositories/locales.ts";
import { ID } from "../types/id.ts"; import { ID } from "../types/id.ts";
type HelloResponse = {
id: number;
locale: string;
message: string;
};
/** /**
* Display the iconic Hello, World in a random locale * 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 * Display the iconic Hello, World in a locale identified by id
* @param id Unique identifier * @param id Unique identifier
*/ */
export const sayHello = (id: ID): string => { export const sayHello = (id: ID): HelloResponse => {
return getLocaleById(id.value); return {
id: id.value,
locale: "",
message: getLocaleById(id.value),
};
}; };