-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: first draft of a small docs and test cleanup
- Loading branch information
1 parent
0667dff
commit 640c8e3
Showing
4 changed files
with
211 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import ezs from '@ezs/core/src'; | ||
import from from 'from'; | ||
import assert from 'assert'; | ||
import tune from '../src/tune'; | ||
|
||
ezs.addPath(__dirname); | ||
|
||
const simpleObject = [ | ||
{ | ||
id: 1, | ||
value: 1 | ||
}, | ||
{ | ||
id: 2, | ||
value: 2 | ||
} | ||
]; | ||
|
||
describe('tune', () => { | ||
it('should normalize simple object', async () => { | ||
ezs.use({ tune }); | ||
|
||
const res = await (new Promise((resolve) => { | ||
const result = []; | ||
from(simpleObject) | ||
.pipe(ezs('tune')) | ||
.on('data', (chunk) => { | ||
assert(typeof chunk === 'object'); | ||
result.push(chunk); | ||
}) | ||
.on('end', () => { | ||
resolve(result); | ||
}); | ||
})); | ||
|
||
assert.equal(res[0].id, '0000000000000000001.00000000000000000000'); | ||
assert.equal(res[1].id, '0000000000000000002.00000000000000000000'); | ||
|
||
assert.equal(res[0].value, simpleObject[0]); | ||
assert.equal(res[1].value, simpleObject[1]); | ||
}); | ||
}); |