salix/back/methods/campaign/spec/latest.spec.js

19 lines
661 B
JavaScript
Raw Normal View History

2020-10-05 06:50:07 +00:00
const app = require('vn-loopback/server/server');
describe('campaign latest()', () => {
it('should return the campaigns from the last year', async() => {
let response = await app.models.Campaign.latest();
const lastYearDate = new Date();
lastYearDate.setFullYear(lastYearDate.getFullYear() - 1);
const lastYear = lastYearDate.getFullYear();
const randomIndex = Math.floor(Math.random() * 3);
const campaignDated = response[randomIndex].dated;
const campaignYear = campaignDated.getFullYear();
expect(response.length).toEqual(3);
expect(campaignYear).toEqual(lastYear);
});
});