mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-06 01:56:40 +00:00
more return information
This commit is contained in:
parent
97506731e1
commit
2314e82341
2 changed files with 13 additions and 3 deletions
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue