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", () => {
const result = sayRandomHello();
const actual = typeof result;
const expected = "string";
const expected = "object";
assertStrictEquals(actual, expected);
});

View file

@ -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),
};
};