mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-12 12:56:38 +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", () => {
|
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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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),
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue