Skip to content

Commit

Permalink
Merge pull request #6 from zephyrec/refactoring/test-and-better-docum…
Browse files Browse the repository at this point in the history
…entation

Refactoring/test and better documentation
  • Loading branch information
zephyrec committed May 15, 2017
2 parents 280a805 + d9da34e commit be59d30
Show file tree
Hide file tree
Showing 28 changed files with 659 additions and 1,236 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# Ignore locally installed dependencies
/node_modules/

# Ignore build products
/dist/

# Ignore any IDE specific file
# Ignore IDE specific files
/.idea/
/.vscode/

# Ignore build products
/src/*.js
/src/*.d.ts

# Ignore coverage report files
/.nyc_output/
Expand Down
7 changes: 5 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# Ignore source files
/src/
/src/*.ts
# But do not ignore declaration files
!/src/*.d.ts

# Ignore documentation generated by the command `npm run typedoc`
/docs/
Expand All @@ -13,9 +15,10 @@

# Ignore any IDE specific file
/.idea/
/.vscode/

# Ignore project tests
/test/
/src/*.spec.js

# Ignore coverage report files
/.nyc_output/
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ cache:
directories:
- node_modules

before_script:
- npm run tslint

after_success:
- './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls'
28 changes: 8 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# REST HAL Test Tools
# Tests for RESTful APIs using HAL+JSON media type
[![Build Status](https://travis-ci.org/zephyrec/rest-hal-test-tools.svg?branch=master)](https://travis-ci.org/zephyrec/rest-hal-test-tools)
[![Coverage Status](https://coveralls.io/repos/github/zephyrec/rest-hal-test-tools/badge.svg?branch=master)](https://coveralls.io/github/zephyrec/rest-hal-test-tools?branch=master)

Expand All @@ -7,6 +7,13 @@ This project provide common tests for [REST][rest] APIs that use the
are meant to be used with the [AVA][ava] JavaScript test runner and
employ the [SuperTest][supertest] HTTP assertion library.

## Installation
`rest-hal-test-tools` runs on Node.js and is available as an NPM
package. You can install `rest-hal-test-tools` in your project's
directory as usual:

npm install @zephyrec/rest-hal-test-tools --save-dev

## Reference Documentation
Reference documentation for this project can be generated from the
inline comments on source code using the [Typedoc][typedoc]
Expand All @@ -19,25 +26,6 @@ This package is written in [Typescript][typescript] and it provide a
declaration file for its content so you can use it on Typescript
projects without problems.

## Example Usage
The following code demonstrate howto use the library:

```javascript
const ava = require('ava');
const restHalTestTools = require('@zephyrec/rest-hal-test-tools');
const superTest = require('supertest');

// setup test context by providing the resource and the agent
ava.beforeEach(t => {
t.context.resource = '/some/resource';
t.context.agent = supertest('https://some.api');
});

// use tests provided by the rest-hal-test-tools package
ava(restHalTestTools.resourceImplementOptionsMethod);
ava(restHalTestTools.resourceImplementGetMethod);
```

## Licensing

The code in this project is licensed under MIT license.
Expand Down
10 changes: 5 additions & 5 deletions docs/assets/js/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions docs/globals.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ <h3>External modules</h3>
<li class="tsd-kind-external-module"><a href="modules/_index_.html" class="tsd-kind-icon">"index"</a></li>
<li class="tsd-kind-external-module"><a href="modules/_resource_implement_get_method_.html" class="tsd-kind-icon">"resource-<wbr>implement-<wbr>get-<wbr>method"</a></li>
<li class="tsd-kind-external-module"><a href="modules/_resource_implement_options_method_.html" class="tsd-kind-icon">"resource-<wbr>implement-<wbr>options-<wbr>method"</a></li>
<li class="tsd-kind-external-module"><a href="modules/_rest_hal_test_context_.html" class="tsd-kind-icon">"rest-<wbr>hal-<wbr>test-<wbr>context"</a></li>
<li class="tsd-kind-external-module"><a href="modules/_resource_options_method_allow_get_.html" class="tsd-kind-icon">"resource-<wbr>options-<wbr>method-<wbr>allow-<wbr>get"</a></li>
<li class="tsd-kind-external-module"><a href="modules/_test_context_.html" class="tsd-kind-icon">"test-<wbr>context"</a></li>
</ul>
</section>
</div>
Expand All @@ -96,7 +97,10 @@ <h3>External modules</h3>
<a href="modules/_resource_implement_options_method_.html">"resource-<wbr>implement-<wbr>options-<wbr>method"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="modules/_rest_hal_test_context_.html">"rest-<wbr>hal-<wbr>test-<wbr>context"</a>
<a href="modules/_resource_options_method_allow_get_.html">"resource-<wbr>options-<wbr>method-<wbr>allow-<wbr>get"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="modules/_test_context_.html">"test-<wbr>context"</a>
</li>
</ul>
</nav>
Expand Down
30 changes: 11 additions & 19 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,19 @@ <h1> @zephyrec/rest-hal-test-tools</h1>
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<h1 id="rest-hal-test-tools">REST HAL Test Tools</h1>
<h1 id="tests-for-restful-apis-using-hal-json-media-type">Tests for RESTful APIs using HAL+JSON media type</h1>
<p><a href="https://travis-ci.org/zephyrec/rest-hal-test-tools"><img src="https://travis-ci.org/zephyrec/rest-hal-test-tools.svg?branch=master" alt="Build Status"></a>
<a href="https://coveralls.io/github/zephyrec/rest-hal-test-tools?branch=master"><img src="https://coveralls.io/repos/github/zephyrec/rest-hal-test-tools/badge.svg?branch=master" alt="Coverage Status"></a></p>
<p>This project provide common tests for <a href="https://en.wikipedia.org/wiki/Representational_state_transfer">REST</a> APIs that use the
<a href="https://tools.ietf.org/html/draft-kelly-json-hal-08">JSON Hypertext Application Language</a> Media Type. Provided tests
are meant to be used with the <a href="https://github.com/avajs">AVA</a> JavaScript test runner and
employ the <a href="https://github.com/visionmedia/supertest">SuperTest</a> HTTP assertion library.</p>
<h2 id="reference-documentation">Reference Documentation</h2>
<h2 id="installation">Installation</h2>
<p><code>rest-hal-test-tools</code> runs on Node.js and is available as an NPM
package. You can install <code>rest-hal-test-tools</code> in your project&#39;s
directory as usual:</p>
<pre><code><span class="hljs-selector-tag">npm</span> <span class="hljs-selector-tag">install</span> @<span class="hljs-keyword">zephyrec</span>/<span class="hljs-keyword">rest</span>-<span class="hljs-keyword">hal</span>-<span class="hljs-keyword">test</span>-<span class="hljs-keyword">tools</span> --save-dev
</code></pre><h2 id="reference-documentation">Reference Documentation</h2>
<p>Reference documentation for this project can be generated from the
inline comments on source code using the <a href="http://typedoc.org/">Typedoc</a>
documentation generator. The following command ease the task:</p>
Expand All @@ -80,22 +85,6 @@ <h2 id="reference-documentation">Reference Documentation</h2>
<p>This package is written in <a href="https://www.typescriptlang.org/">Typescript</a> and it provide a
declaration file for its content so you can use it on Typescript
projects without problems.</p>
<h2 id="example-usage">Example Usage</h2>
<p>The following code demonstrate howto use the library:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> ava = <span class="hljs-built_in">require</span>(<span class="hljs-string">'ava'</span>);
<span class="hljs-keyword">const</span> restHalTestTools = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@zephyrec/rest-hal-test-tools'</span>);
<span class="hljs-keyword">const</span> superTest = <span class="hljs-built_in">require</span>(<span class="hljs-string">'supertest'</span>);

<span class="hljs-comment">// setup test context by providing the resource and the agent</span>
ava.beforeEach(<span class="hljs-function"><span class="hljs-params">t</span> =&gt;</span> {
t.context.resource = <span class="hljs-string">'/some/resource'</span>;
t.context.agent = supertest(<span class="hljs-string">'https://some.api'</span>);
});

<span class="hljs-comment">// use tests provided by the rest-hal-test-tools package</span>
ava(restHalTestTools.resourceImplementOptionsMethod);
ava(restHalTestTools.resourceImplementGetMethod);
</code></pre>
<h2 id="licensing">Licensing</h2>
<p>The code in this project is licensed under MIT license.</p>
</div>
Expand All @@ -116,7 +105,10 @@ <h2 id="licensing">Licensing</h2>
<a href="modules/_resource_implement_options_method_.html">"resource-<wbr>implement-<wbr>options-<wbr>method"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="modules/_rest_hal_test_context_.html">"rest-<wbr>hal-<wbr>test-<wbr>context"</a>
<a href="modules/_resource_options_method_allow_get_.html">"resource-<wbr>options-<wbr>method-<wbr>allow-<wbr>get"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="modules/_test_context_.html">"test-<wbr>context"</a>
</li>
</ul>
</nav>
Expand Down

0 comments on commit be59d30

Please sign in to comment.