Skip to content
This repository was archived by the owner on Jul 12, 2019. It is now read-only.

Commit 1ae295c

Browse files
committedOct 26, 2018
Add unit test boilerplate
1 parent 82c791e commit 1ae295c

File tree

6 files changed

+134
-3
lines changed

6 files changed

+134
-3
lines changed
 

‎.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.vscode
3+
yarn.lock
4+
test/index.html
5+
test/test.compiled.js

‎README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ cd tmdb-ui-cyclejs
99
npm install
1010
```
1111

12-
#### Running:
12+
#### Run:
1313
```
1414
npm start
1515
```
16+
17+
#### Test:
18+
```
19+
npm test
20+
```

‎package-lock.json

+77
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"private": true,
66
"main": "webpack.config.js",
77
"scripts": {
8-
"test": "echo \"Error: no test specified\" && exit 1",
8+
"test": "webpack --entry ./test/test.js --output test/test.compiled.js --display none && mocha test/test.compiled.js",
99
"start": "webpack-dev-server --mode=development --open 'Google Chrome'",
1010
"build": "webpack"
1111
},
@@ -29,6 +29,7 @@
2929
"copy-webpack-plugin": "^4.5.4",
3030
"css-loader": "^1.0.0",
3131
"html-webpack-plugin": "^3.2.0",
32+
"mocha": "^5.2.0",
3233
"style-loader": "^0.23.1",
3334
"webpack": "^4.22.0",
3435
"webpack-cli": "^3.1.2",

‎src/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import css from './main.css';
2525
import { HomePage } from './view/home/HomePage.js';
2626
import { MovieDetailsPage } from './view/details/MovieDetailsPage.js';
2727

28-
function main(sources) {
28+
export function main(sources) {
2929
const homePageClick$ = sources.DOM
3030
.select('.home, .view-container[data-active-page="item"] > .view[data-page="home"]')
3131
.events('click');

‎test/test.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {mockDOMSource} from '@cycle/dom';
2+
import {select} from 'snabbdom-selector'
3+
import {mockTimeSource} from '@cycle/time';
4+
import {main} from '../src/main';
5+
6+
7+
var assert = require('assert');
8+
describe('Array', function() {
9+
describe('#indexOf()', function() {
10+
it('should return -1 when the value is not present', function() {
11+
assert.equal([1,2,3].indexOf(4), -1);
12+
});
13+
});
14+
});
15+
16+
17+
// describe('main', () => {
18+
// it('increments and decrements in response to clicks', (done) => {
19+
// const Time = mockTimeSource();
20+
//
21+
// const addClick$ = Time.diagram(`---x--x-------x--x--|`);
22+
// const subtractClick$ = Time.diagram(`---------x----------|`);
23+
// const expectedCount$ = Time.diagram(`0--1--2--1----2--3--|`);
24+
//
25+
// const DOM = mockDOMSource({
26+
// '.add': {
27+
// click: addClick$
28+
// },
29+
//
30+
// '.subtract': {
31+
// click: subtractClick$
32+
// },
33+
// });
34+
//
35+
// const counter = Counter({DOM});
36+
//
37+
// const count$ = counter.DOM.map(vtree => select('.count', vtree)[0].text);
38+
//
39+
// Time.assertEqual(count$, expectedCount$)
40+
//
41+
// Time.run(done);
42+
// });
43+
// });

0 commit comments

Comments
 (0)
This repository has been archived.