diff options
author | Vincent LE GOFF <g_n_s@hotmail.fr> | 2019-03-15 23:51:47 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-15 18:51:47 -0400 |
commit | 23108b06b9c8803e44e0e251bdbe193a5cf16ad6 (patch) | |
tree | 3c6cf71d2e53b59630160ae4629729e2b9c2d617 | |
parent | 62761a4e3a12e123d32c7d78a06f6565118d63b4 (diff) |
Add test style guide (#1918)
-rw-r--r-- | website/style_guide.md | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/website/style_guide.md b/website/style_guide.md index c2ed2c483..73fbe698a 100644 --- a/website/style_guide.md +++ b/website/style_guide.md @@ -270,3 +270,30 @@ the first column of the comment. For example: Code examples should not contain additional comments. It is already inside a comment. If it needs further comments is not a good example. + +## Each module should come with tests + +Each module should come with its test as a sibling with the name +`modulename_test.ts`. For example the module `foo.ts` should come with its +sibling `foo_test.ts`. + +## Unit Tests should be explicit + +For a better understanding of the tests, function should be correctly named as +its prompted throughout the test command. Like: + +``` +test myTestFunction ... ok +``` + +Example of test: + +```ts +import { assertEquals } from "https://deno.land/std@v0.3.1/testing/asserts.ts"; +import { test } from "https://deno.land/std@v0.3.1/testing/mod.ts"; +import { foo } from "./mod.ts"; + +test(function myTestFunction() { + assertEquals(foo(), { bar: "bar" }); +}); +``` |