import and test examples

This commit is contained in:
Ruidy 2021-02-18 20:10:55 +01:00
parent 0d8f3272bf
commit 36e2d0d9a6
3 changed files with 24 additions and 0 deletions

6
examples/hello.ts Normal file
View file

@ -0,0 +1,6 @@
// Library exporting `sayHello` function
const capitalize = (word: string) =>
`${word.charAt(0).toUpperCase()}${word.toLowerCase().slice(1)}`;
export const sayHello = (name: string) => `Hello ${capitalize(name)}`;

7
examples/import.ts Normal file
View file

@ -0,0 +1,7 @@
// Import as ES modules
import { sayHello } from "./hello.ts";
const name = Deno.args[0];
console.log(sayHello(name));

11
examples/test.ts Normal file
View file

@ -0,0 +1,11 @@
// Run using deno test
import { assert } from "https://deno.land/std@0.87.0/testing/asserts.ts";
Deno.test("Hello test", () => {
assert("Hello");
});
Deno.test("Hello test", () => {
assert(false);
});