-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test for multiple called back is added.
- Loading branch information
Tomohito Nakayama
committed
Mar 17, 2016
1 parent
51254ee
commit d08a84a
Showing
2 changed files
with
55 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict'; | ||
|
||
var jf = require('../../'), | ||
expect = require('chai').expect, | ||
fs = require('fs'), | ||
path = require('path'); | ||
|
||
let testPath = './' + Math.random() + '.json'; | ||
let testPath2 = './' + Math.random() + '.json'; | ||
let testPath3 = './' + Math.random() + '.json'; | ||
var testValue = { msg: Math.random().toString() }; | ||
var new_testValue = { msg: Math.random().toString() }; | ||
|
||
describe('called back function ', function () { | ||
it('can be called multiple times with new file path', function (done) { | ||
|
||
var count = 0; | ||
jf.filed( testPath ) | ||
.io( | ||
function( obj, filePath) { | ||
return testValue; | ||
} | ||
).calledback( | ||
function(obj, filePath, callback){ | ||
setTimeout( | ||
function(){ | ||
console.log("called back user process") | ||
callback( new_testValue, testPath ); | ||
callback( new_testValue, testPath2 ); | ||
callback( new_testValue, testPath3 ); | ||
}, | ||
10); | ||
} | ||
).pass( | ||
function(obj, filePath){ | ||
expect( path.resolve( testPath ) == filePath || | ||
path.resolve( testPath2 ) == filePath || | ||
path.resolve( testPath3 ) == filePath ).to.eql(true); | ||
expect(obj).to.eql(new_testValue); | ||
|
||
count ++; | ||
if( count == 3 ) done(); | ||
|
||
} | ||
).exec(); | ||
|
||
}); | ||
|
||
setTimeout( | ||
function(){ | ||
}, | ||
20); | ||
|
||
}); |