quality: web debt batch (tests runner, FireContainer, rate-limit, maps, i18n)
Independent-of-prod quality debt from PENDIENTE.md §2: - test: migrate broken Jest -> meteortesting:mocha. Tests rewritten to chai + Meteor 3 async APIs, moved to test/server/ (server-only). test/server/ 00-setup.test.js re-runs the collection2/accounts init that `meteor test` skips (no server/main.js). New comments method + mediaAnalyzers coverage. Dropped rest.test.js (removed meteor/http; covered by smoke/). 36 passing. - fix: scope FireContainer read by the URL _id on the archive route instead of a selector-less FiresCollection.findOne() (imports/ui/pages/Fires/Fires.js). - feat: rate-limit abusable publications via rateLimitSubscriptions (fireFrom* and comments.forReference 5/1000ms; geo subs 10/1000ms). - perf: append loading=async to the Google Maps loader URL (Gkeys.js). - deps: meteor-accounts-t9n 2.0 -> 2.6 (no gl build -> keep gl->es fallback, documented); add 3 missing gl/common.json keys (0 missing now). - deps: drop jest/babel/enzyme, add chai.
This commit is contained in:
parent
bc778bfd97
commit
6b6f02d92d
27 changed files with 602 additions and 7042 deletions
51
test/server/tweets.test.js
Normal file
51
test/server/tweets.test.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/* eslint-env mocha */
|
||||
/* eslint-disable func-names, prefer-arrow-callback */
|
||||
/* eslint-disable import/no-absolute-path */
|
||||
|
||||
import { expect } from 'chai';
|
||||
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', () => {
|
||||
it('No fires', () => {
|
||||
expect(composeIberiaTweet(0, { })).to.equal('');
|
||||
});
|
||||
|
||||
it('a fire in a zone', () => {
|
||||
expect(composeIberiaTweet(1, tr({ Asturias: 1 }))).to.equal('Un #fuego activo en #Asturias');
|
||||
});
|
||||
|
||||
it('some fires in a zone', () => {
|
||||
expect(composeIberiaTweet(4, tr({ Asturias: 4 }))).to.equal('4 #fuegos activos en #Asturias');
|
||||
});
|
||||
|
||||
it('some fires in two zones', () => {
|
||||
expect(composeIberiaTweet(5, tr({ Asturias: 1, Madrid: 4 }))).to.equal('Un #fuego activo en #Asturias y otros 4 en #Madrid');
|
||||
});
|
||||
|
||||
it('some fires in some zones', () => {
|
||||
expect(composeIberiaTweet(8, tr({ Catalunya: 3, Asturias: 1, Madrid: 4 }))).to.equal('3 #fuegos activos en #Catalunya, otro en #Asturias y otros 4 en #Madrid');
|
||||
});
|
||||
|
||||
it('other fires in some zones', () => {
|
||||
expect(composeIberiaTweet(6, tr({ Catalunya: 1, Asturias: 1, Madrid: 4 }))).to.equal('Un #fuego activo en #Catalunya, otro en #Asturias y otros 4 en #Madrid');
|
||||
});
|
||||
|
||||
it('other fires in two zones', () => {
|
||||
expect(composeIberiaTweet(2, tr({ Catalunya: 1, Asturias: 1 }))).to.equal('Un #fuego activo en #Catalunya y otro en #Asturias');
|
||||
});
|
||||
|
||||
it('many fires in many zones', () => {
|
||||
expect(composeIberiaTweet(11, tr({
|
||||
Cataluña: 3, Cantabria: 1, Andalucia: 4, Galicia: 1, Madrid: 2
|
||||
}))).to.equal('3 #fuegos activos en #Cataluña, otro en #Cantabria, otros 4 en #Andalucia, otro en #Galicia y otros 2 en #Madrid');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue