Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test style guide #1918

Merged
merged 5 commits into from
Mar 15, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions website/style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,39 @@ 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 { assertStrContains } from "https://deno.land/std@v0.3.1/testing/asserts.ts";
import { test } from "https://deno.land/std@v0.3.1/testing/mod.ts";

test(function testingAssertStringContains() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the name of the function here should correspond to the output you give above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't thought about it but yes

assertStrContains("Denosaurus", "saur");
assertStrContains("Denosaurus", "Deno");
assertStrContains("Denosaurus", "rus");
let didThrow;
try {
assertStrContains("Denosaurus", "Raptor");
didThrow = false;
} catch (e) {
didThrow = true;
}
assertEquals(didThrow, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a smaller one line example with just a single assertEquals... I think all this code distracts from the point the style guide is making. This isn't documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edited

});
```