19 lines
661 B
JavaScript
19 lines
661 B
JavaScript
|
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);
|
||
|
});
|
||
|
});
|