Skip to content

Commit

Permalink
feature #15: guide/tests section
Browse files Browse the repository at this point in the history
  • Loading branch information
silkentrance committed Apr 3, 2019
1 parent fc8b3dd commit 78fd8ca
Showing 1 changed file with 188 additions and 0 deletions.
188 changes: 188 additions & 0 deletions pages/guide/tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
layout: guide
section: guide
role: page
order: 50
toc: true
title: Tests
label: Tests
description: |
Tests
---

{:.toc}
## Tests

{:.toc}
## Synchronous Tests

{% highlight TypeScript linenos %}
import { suite, test } from '@testdeck/mocha';
import { assert } from 'chai';

@suite
class Suite {

@test
test() {

assert.isOk(false);
}
}
{% endhighlight %}

### Run Tests

{% highlight shell %}
npm test

{% endhighlight %}


{:.toc}
## Asynchronous Tests


{:.toc}
### Callback Style

{% highlight TypeScript linenos %}
import { suite, test } from '@testdeck/mocha';
import { assert } from 'chai';

@suite
class Suite {

@test
test(done) {

setTimeout(() => {

try {
assert.isOk(false);
} catch (err) {
done(err);
}
}, 100);
}
}
{% endhighlight %}

#### Run Tests

{% highlight shell %}
npm test

...

Suite
1) test

...

1) Suite
test:
AssertionError: expected false to be truthy

...
{% endhighlight %}


{:.toc}
### Promise Style

{% highlight TypeScript linenos %}
import { suite, test } from '@testdeck/mocha';
import { assert } from 'chai';

@suite
class Suite {

@test
test() {

return new Promise((resolve, reject) => {

try {
assert.isOk(false);
resolve(null);
} catch (err) {
reject(err);
}
});
}
}
{% endhighlight %}

#### Run Tests

{% highlight shell %}
npm test

...

Suite
1) test

...

1) Suite
test:
AssertionError: expected false to be truthy

...
{% endhighlight %}


{:.toc}
### Async/Await Style

{% highlight TypeScript linenos %}
import { suite, test } from '@testdeck/mocha';
import { assert } from 'chai';

@suite
class Suite {

@test
async test() {

return new Promise((resolve, reject) => {

try {
assert.isOk(false);
resolve(null);
} catch (err) {
reject(err);
}
});
}
}
{% endhighlight %}

#### Run Tests

{% highlight shell %}
npm test

...

Suite
1) test

...

1) Suite
test:
AssertionError: expected false to be truthy

...
{% endhighlight %}

0 comments on commit 78fd8ca

Please sign in to comment.