Blame view

node_modules/htmlparser2/test/02-stream.js 628 Bytes
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  var helper = require("./test-helper.js"),
  	Stream = require("..").WritableStream,
  	fs = require("fs"),
  	path = require("path");
  
  helper.mochaTest("Stream", __dirname, function(test, cb){
  	var filePath = path.join(__dirname, "Documents", test.file);
  	fs.createReadStream(filePath).pipe(
  		new Stream(
  			helper.getEventCollector(function(err, events){
  				cb(err, events);
  
  				var handler = helper.getEventCollector(cb),
  				    stream = new Stream(handler, test.options);
  
  				fs.readFile(filePath, function(err, data){
  					if(err) throw err;
  					else stream.end(data);
  				});
  			}
  		), test.options)
  	).on("error", cb);
  });