Skip to content

Commit 2628edc

Browse files
committed
tests + documentation.
1 parent 8c4fe93 commit 2628edc

7 files changed

Lines changed: 39 additions & 12 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ $ npm install spex
2020
## Usage
2121

2222
* For any [Promises/A+] library: [Promise], [Bluebird], [When], [Q], [RSVP], etc.
23-
```javascript
23+
24+
```js
2425
var promise = require('bluebird');
2526
var spex = require('spex')(promise);
2627
```
28+
2729
* For ES6 Promise:
28-
```javascript
30+
```js
2931
var spex = require('spex')(Promise);
3032
```
3133

jsdoc/fixLinks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var links = {
1717

1818
function fixLinks(source) {
1919
return source.replace(/\$\[[a-z0-9\s/+-.]+\]/gi, function (name) {
20-
var sln = name.replace(/\$\[|\]/g, ''); // stripped link name;
20+
var sln = name.replace(/\$\[|]/g, ''); // stripped link name;
2121
if (sln in links) {
2222
return '<a href="' + links[sln] + '">' + sln + '</a>';
2323
}

jsdoc/tutorials/batch.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ And this is where method [batch] helps:
2828

2929
Let's start with a positive example, and throw in a few combinations of [mixed values].
3030

31-
```javascript
31+
```js
3232
var spex = require('spex')(Promise);
3333
3434
// function that returns a promise;
@@ -102,4 +102,5 @@ ERROR: [ 'World' ]
102102
This is just to simplify quick access to the list of errors that occurred.
103103

104104
[batch]:http://vitaly-t.github.io/spex/global.html#batch
105-
[mixed values]:https://github.com/vitaly-t/spex/wiki/Mixed-Values
105+
[mixed values]:http://vitaly-t.github.io/spex/tutorial-mixed.html
106+

jsdoc/tutorials/sequencing.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Result: [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ]
5252

5353
Now let's create the same sequence using spex:
5454

55-
```javascript
55+
```js
5656
function source(index, data) {
5757
return nextPrime(data);
5858
}
@@ -83,13 +83,16 @@ Let's see how the [sequence] performs compared to the direct calculation as we i
8383

8484
* `direct` - direct sequence calculation;
8585
* `number` - using [sequence] with the `source` that returns numbers:
86-
```javascript
86+
87+
```js
8788
function source(index, data) {
8889
return nextPrime(data);
8990
}
9091
```
92+
9193
* `promise` - using [sequence] with the `source` that returns promises:
92-
```javascript
94+
95+
```js
9396
function source(index, data) {
9497
return Promise.resolve(nextPrime(data));
9598
}
@@ -98,6 +101,6 @@ function source(index, data) {
98101
* Two measurements for the [sequence]: ES6 Promise / Bluebird
99102
* Measured under NodeJS 4.1.1, 64-bit, with i7-4770 @ 3.85GHz
100103

101-
[mixed value]:https://github.com/vitaly-t/spex/wiki/Mixed-Values
104+
[mixed value]:http://vitaly-t.github.io/spex/tutorial-mixed.html
102105
[sequence]:http://vitaly-t.github.io/spex/global.html#sequence
103106
[Bluebird]:https://github.com/petkaantonov/bluebird

jsdoc/tutorials/streaming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ DATA: [ 'zero', 'one', 'two', 'three' ]
5656
And if we run the same sequence without tracking (default):
5757

5858
```js
59-
spex.sequence(source, dest)
59+
spex.sequence(source, {dest: dest})
6060
.then(function (data) {
6161
console.log('DATA:', data); // print result;
6262
});

jsdoc/tutorials/throttling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function dest(index, data, delay) {
8282
});
8383
}
8484
85-
spex.sequence(source, dest)
85+
spex.sequence(source, {dest: dest})
8686
.then(function (data) {
8787
console.log('DATA:', data);
8888
});

test/ext/stream/readSpec.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('Stream/Read - positive', function () {
113113
var stm;
114114

115115
beforeEach(function () {
116-
stm = fs.createReadStream(__filename);
116+
stm = fs.createReadStream(__filename, {encoding: 'utf8'});
117117
});
118118

119119
afterEach(function () {
@@ -128,6 +128,7 @@ describe('Stream/Read - positive', function () {
128128
result = data;
129129
done();
130130
});
131+
131132
function receiver() {
132133
return promise.resolve();
133134
}
@@ -145,6 +146,7 @@ describe('Stream/Read - positive', function () {
145146
result = data;
146147
done();
147148
});
149+
148150
function receiver() {
149151
return promise.resolve();
150152
}
@@ -170,6 +172,7 @@ describe('Stream/Read - positive', function () {
170172
.then(function () {
171173
done();
172174
});
175+
173176
function receiver(index, data, delay) {
174177
r = {
175178
index: index,
@@ -187,4 +190,22 @@ describe('Stream/Read - positive', function () {
187190
});
188191
});
189192

193+
describe('chunk read', function () {
194+
var result;
195+
beforeEach(function (done) {
196+
spex.stream.read(stm, receiver, {readChunks: true})
197+
.then(function () {
198+
done();
199+
});
200+
201+
function receiver(index, data, delay) {
202+
result = data;
203+
}
204+
});
205+
it('must receive all the data', function () {
206+
expect(Array.isArray(result)).toBe(true);
207+
expect(result.length).toBe(1);
208+
expect(result[0].length).toBeGreaterThan(500);
209+
});
210+
});
190211
});

0 commit comments

Comments
 (0)