mirror of
https://github.com/rjNemo/deno_tuto
synced 2026-06-12 12:56:39 +00:00
import and test examples
This commit is contained in:
parent
0d8f3272bf
commit
36e2d0d9a6
3 changed files with 24 additions and 0 deletions
6
examples/hello.ts
Normal file
6
examples/hello.ts
Normal 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
7
examples/import.ts
Normal 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
11
examples/test.ts
Normal 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);
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue