6
Benaynı içeriği
GET /files/<hash>
döner akışı olarak dosya benim istirahat Servisi test etmek mocha/Supertest/should.js kullanıyorum sahip dosyaları ileri süren.
Dosya içeriğinin aynı olması gerektiğini should.js'de nasıl iddia edebilirim?
İlk: okumak için bir döngü kullanarak
:
tmpBuf.toString() === testBuf.toString();
İkinci sonuç dizeleri karşılaştırın
it('should return file as stream', function (done) {
var writeStream = fs.createWriteStream('test/fixtures/tmp.json');
var req = api.get('/files/676dfg1430af3595');
req.on('end', function(){
var tmpBuf = fs.readFileSync('test/fixtures/tmp.json');
var testBuf = fs.readFileSync('test/fixtures/test.json');
// How to assert with should.js file contents are the same (tmpBuf == testBuf)
// ...
done();
});
});