Commit ddb039de authored by tobinski's avatar tobinski
Browse files

Add analyser test

parent 262b82c1
import chai = require('chai');
import chaiAsPromised = require('chai-as-promised');
import fs = require('fs');
import Core, {InterfaceCore} from 'geolinker-common/dist/core';
import ReporterCounter from 'geolinker-common/dist/stream/reporter-counter';
import converter from 'julian-gregorian';
import {describe, it} from 'mocha';
import nconf = require('nconf');
import WikidataNormalizerTransformer from '../src/wikidata-normalizer-transformer';
import {timeToDate, wikidataTimePropertiesLoader} from '../src/wikidata-utils';
import MockReadable from './mock-readable';
import MockReporter from './mock-reporter';
import MockWriteable from './mock-writeable';
import WikidataAnalyserTransformer from '../src/wikidata-analyser-transformer';
process.env['log-dir'] = '/tmp';
process.env.reporter_url = 'localhost:9999';
nconf.set('log-dir', './log');
process.env.NODE_ENV = 'test';
const coreMock: InterfaceCore = new Core('test', 'none');
describe('Test wikidata-analyser-transformer', () => {
before((done) => {
chai.should();
chai.use(chaiAsPromised);
done();
});
it('Try to transform data', (done) => {
const options = {
objectMode: true,
nconf,
uriBuilder: coreMock.getUriBuilder(),
};
const analyser = new WikidataAnalyserTransformer(options);
// listener to check output
analyser.on('data', (data) => {
const testMessage = {
from: 'https://www.wikidata.org/wiki/Q13038',
to:
['https://g.co/kg/m/0gdcn4', 'http://geonames.org/8261346'],
relation: {type: 'same_as', author: undefined, weight: 1},
};
data.should.be.deep.equal(testMessage);
done();
});
// build chunk
const chunck = {
parsed: {
data: Buffer.from(fs.readFileSync(__dirname + '/fixtures/place.json')),
},
};
analyser.write(chunck);
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment