Fix tweet tests

This commit is contained in:
vjrj 2018-05-02 19:04:00 +02:00
parent 7bb004cdd2
commit 3eb2e4ff28

View file

@ -5,38 +5,47 @@
import { chai } from 'meteor/practicalmeteor:chai'; import { chai } from 'meteor/practicalmeteor:chai';
import { composeIberiaTweet } from '/imports/api/ActiveFires/server/tweetFiresInZone'; import { composeIberiaTweet } from '/imports/api/ActiveFires/server/tweetFiresInZone';
const tr = (stats) => {
const keys = Object.keys(stats);
const newStats = [];
keys.map((key) => {
newStats[key] = { count: stats[key] };
});
return newStats;
};
describe('compose tweets of fires', () => { describe('compose tweets of fires', () => {
it('No fires', async () => { it('No fires', async () => {
chai.expect('').to.deep.equal(composeIberiaTweet(0, { })); chai.expect('').to.deep.equal(composeIberiaTweet(0, { }));
}); });
it('a fire in a zone', async () => { it('a fire in a zone', async () => {
chai.expect('Un #fuego activo en #Asturias').to.deep.equal(composeIberiaTweet(1, { Asturias: 1 })); chai.expect('Un #fuego activo en #Asturias').to.deep.equal(composeIberiaTweet(1, tr({ Asturias: 1 })));
}); });
it('some fires in a zone', async () => { it('some fires in a zone', async () => {
chai.expect('4 #fuegos activos en #Asturias').to.deep.equal(composeIberiaTweet(4, { Asturias: 4 })); chai.expect('4 #fuegos activos en #Asturias').to.deep.equal(composeIberiaTweet(4, tr({ Asturias: 4 })));
}); });
it('some fires in two zones', async () => { it('some fires in two zones', async () => {
chai.expect('Un #fuego activo en #Asturias y otros 4 en #Madrid').to.deep.equal(composeIberiaTweet(5, { Asturias: 1, Madrid: 4 })); chai.expect('Un #fuego activo en #Asturias y otros 4 en #Madrid').to.deep.equal(composeIberiaTweet(5, tr({ Asturias: 1, Madrid: 4 })));
}); });
it('some fires in some zones', async () => { it('some fires in some zones', async () => {
chai.expect('3 #fuegos activos en #Catalunya, otro en #Asturias y otros 4 en #Madrid').to.deep.equal(composeIberiaTweet(8, { Catalunya: 3, Asturias: 1, Madrid: 4 })); chai.expect('3 #fuegos activos en #Catalunya, otro en #Asturias y otros 4 en #Madrid').to.deep.equal(composeIberiaTweet(8, tr({ Catalunya: 3, Asturias: 1, Madrid: 4 })));
}); });
it('other fires in some zones', async () => { it('other fires in some zones', async () => {
chai.expect('Un #fuego activo en #Catalunya, otro en #Asturias y otros 4 en #Madrid').to.deep.equal(composeIberiaTweet(6, { Catalunya: 1, Asturias: 1, Madrid: 4 })); chai.expect('Un #fuego activo en #Catalunya, otro en #Asturias y otros 4 en #Madrid').to.deep.equal(composeIberiaTweet(6, tr({ Catalunya: 1, Asturias: 1, Madrid: 4 })));
}); });
it('other fires in two zones', async () => { it('other fires in two zones', async () => {
chai.expect('Un #fuego activo en #Catalunya y otro en #Asturias').to.deep.equal(composeIberiaTweet(2, { Catalunya: 1, Asturias: 1 })); chai.expect('Un #fuego activo en #Catalunya y otro en #Asturias').to.deep.equal(composeIberiaTweet(2, tr({ Catalunya: 1, Asturias: 1 })));
}); });
it('many fires in many zones', async () => { it('many fires in many zones', async () => {
chai.expect('3 #fuegos activos en #Cataluña, otro en #Cantabria, otros 4 en #Andalucia, otro en #Galicia y otros 2 en #Madrid').to.deep.equal(composeIberiaTweet(11, { chai.expect('3 #fuegos activos en #Cataluña, otro en #Cantabria, otros 4 en #Andalucia, otro en #Galicia y otros 2 en #Madrid').to.deep.equal(composeIberiaTweet(11, tr({
Cataluña: 3, Cantabria: 1, Andalucia: 4, Galicia: 1, Madrid: 2 Cataluña: 3, Cantabria: 1, Andalucia: 4, Galicia: 1, Madrid: 2
})); })));
}); });
}); });