biojs-io-graduates
Version:
A parser for the BioJS tutorial graduate list
47 lines (38 loc) • 1.36 kB
JavaScript
var assert = require("chai").assert;
var tutorial = require("../");
// you can find more docu about mocha here
// https://visionmedia.github.io/mocha/
var nock = require('nock');
var testURL = 'http://an.url';
nock(testURL)
.persist()
.get('/list')
.replyWithFile(200, __dirname + '/dummy.list');
describe('Graduates', function(){
// do any init stuff here
beforeEach(function(){
});
describe('parse', function(){
it('should return match with default object', function(){
var dummyObj = {DE: 1, HK: 1, NL: 1, UK: 1, TW: 1};
assert.deepEqual(tutorial.read_static(), dummyObj);
});
});
it('should work with live data', function(done){
tutorial.read(testURL + "/list", function(err, parsed){
// the dummy file contains exactly this obj
var dummyObj = {DE: 1, HK: 1, NL: 1, UK: 1, TW: 1};
assert.deepEqual(parsed, dummyObj);
done(); // you need to call the done callback to resume mocha
});
});
it('should work with live data and promises', function(done){
var p = tutorial.read(testURL + "/list");
p.then(function(parsed){
// the dummy file contains exactly this obj
var dummyObj = {DE: 1, HK: 1, NL: 1, UK: 1, TW: 1};
assert.deepEqual(parsed, dummyObj);
done(); // you need to call the done callback to resume mocha
});
});
});