Commit c2adef22 authored by Dan Allen's avatar Dan Allen

rename test and example code; revising contributing guide

- rename the test file to test/example-test.js (to make it clear its an example)
- move the example code to lib-example
- revise the contributing guide
  * use [.path]_pathname_ syntax for paths
  * fix attribute references
  * wordsmith
parent 17950495
......@@ -302,30 +302,33 @@ To run the test suite, use:
$ yarn test
Note that this command also computes a coverage report using {uri-istanbul}[istanbul].
You can browse this report in a web browser by opening this HTML file: `coverage/index.html`.
You can browse this report in a web browser by opening the HTML file [.path]_coverage/index.html_.
You can run selective parts of the test suite by adding `.only` on `describe()` and/or `it()`.
You can find more details here: https://mochajs.org/#exclusive-tests
=== Select or Skip Tests
You can skip some parts of the test suite by adding `.skip` on `describe()` and/or `it()`.
You can find more details here: https://mochajs.org/#inclusive-tests
You can run select tests by appending `.only` to the `describe` and/or `it` method calls (e.g., `it.only()`.
You can read more about this feature in the https://mochajs.org/#exclusive-tests[mocha documentation].
=== Expectations When Writing Tests
You can skip tests by appending `.skip` to the `describe` and/or `it` method calls (e.g., `describe.skip()`).
You can read more about this feature in the https://mochajs.org/#inclusive-tests[mocha documentation].
If you need to add a new test to the suite, you can use `test/capitalize-test.js` as a reference.
=== Expectations For Writing Tests
If you need to add a new test to the suite, you can use [.path]_test/example-test.js_ as a reference.
It already follows the structure of the project and contains various comments and hints to help you.
Be sure to follow the directions on what to require and the different traps to avoid.
Be sure to follow the directions on what to require and various traps to avoid.
Apart from the classic {uri-chai}[chai] assertions, two plugins are enabled, you'll find the documentation for their APIs here:
Apart from the classic {uri-chai}[chai] assertions, two plugins are enabled.
You'll find the documentation for their APIs here:
* {chai-as-promised}[chai-as-promised] to test promises
* {chai-spies}[chai-spies] to create and test spies on callbacks
* {uri-chai-as-promised}[chai-as-promised] to test promises
* {uri-chai-spies}[chai-spies] to create and test spies on callbacks
If you're working on tests or refactoring tested code, you can run the test suite continuously, using:
$ yarn run test-watch
This will run the test suite each time you modify the code or the test
This command runs the test suite and coverage report each time you save the test or the code under test.
=== Fork the Project
......
......@@ -40,4 +40,4 @@ function capitalizeStream() {
})
}
module.exports = { capitalize, capitalizeArray, capitalizeKeys, asyncCapitalize }
module.exports = { capitalize, capitalizeArray, capitalizeKeys, asyncCapitalize, capitalizeStream }
......@@ -6,7 +6,7 @@
const { expect, spy } = require('./test-utils')
// Require the functions to be tested
const { capitalize, capitalizeArray, capitalizeKeys, asyncCapitalize, capitalizeStream } = require('../lib/capitalize')
const { capitalize, capitalizeArray, capitalizeKeys, asyncCapitalize, capitalizeStream } = require('../lib-example/capitalize.js')
// NOTE: these requires are only there to test arrays
const toStream = require('array-to-stream')
......@@ -26,7 +26,7 @@ describe('text-utils#capitalize', () => {
expect(capitalizedText).to.equal('Hello')
})
it('should let numbers as is', () => {
it('should leave numbers unchanged', () => {
const text = '12'
const capitalizedText = capitalize(text)
expect(capitalizedText).to.equal('12')
......@@ -68,7 +68,7 @@ describe('text-utils#capitalizeKeys', () => {
expect(capitalizedKeysObject).not.to.equal(expectedObject)
})
it('should not capitalize deep keys (it is not recursive)', () => {
it('should not capitalize deep keys (since it is not recursive)', () => {
object.fouR = { valuE: '44' }
expectedObject.Four = { valuE: '44' }
const capitalizedKeysObject = capitalizeKeys(object)
......@@ -89,7 +89,7 @@ describe('text-utils#asyncCapitalize', () => {
return expect(capitalizedText).to.be.fulfilled.and.eventually.equal('Hello')
})
it('should reject if value is null', () => {
it('should reject null value', () => {
const text = null
const capitalizedText = asyncCapitalize(text)
// don't forget to return the promise as the result of the it() test function!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment