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.
32 lines
1.5 KiB
JavaScript
32 lines
1.5 KiB
JavaScript
/* eslint-env mocha */
|
|
/* eslint-disable func-names, prefer-arrow-callback */
|
|
/* eslint-disable import/no-absolute-path */
|
|
|
|
import { expect } from 'chai';
|
|
import ActiveFiresUnion from '/imports/api/ActiveFiresUnion/ActiveFiresUnion';
|
|
|
|
const centerid = { type: 'Point', coordinates: [-5.905956029891968, 43.55727622097011] };
|
|
const shape = { type: 'Polygon', coordinates: [[[-5.9084, 43.5558], [-5.906, 43.5558], [-5.906, 43.5566], [-5.9036, 43.5566], [-5.9036, 43.5583], [-5.9061, 43.5583], [-5.9061, 43.558], [-5.9084, 43.558], [-5.9084, 43.5558]]] };
|
|
// `new Date(...)` (the old test used bare `Date(...)`, which yields a string and
|
|
// fails collection2 schema validation on a Date field).
|
|
const fireUnion = { centerid, shape, when: new Date('2018-05-02T16:11:04.617Z') };
|
|
|
|
describe('activeFireUnion insert', () => {
|
|
it('should insert fire union', async () => {
|
|
// Remove any leftover from a previous run
|
|
const alreadyInserted = await ActiveFiresUnion.findOneAsync({ centerid });
|
|
if (alreadyInserted) {
|
|
await ActiveFiresUnion.removeAsync(alreadyInserted._id);
|
|
}
|
|
|
|
const insertedId = await ActiveFiresUnion.insertAsync(fireUnion);
|
|
ActiveFiresUnion.schema.validate(fireUnion);
|
|
|
|
const inserted = await ActiveFiresUnion.findOneAsync(insertedId);
|
|
delete inserted._id;
|
|
expect(inserted).to.deep.equal(fireUnion);
|
|
|
|
await ActiveFiresUnion.removeAsync(insertedId);
|
|
expect(await ActiveFiresUnion.find({ _id: insertedId }).countAsync()).to.equal(0);
|
|
});
|
|
});
|