between-criterion.model.spec.ts 1.28 KB
Newer Older
Tifenn Guillas's avatar
Tifenn Guillas committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { BetweenCriterion } from './between-criterion.model';

describe('[Search] Model: BetweenCriterion', () => {

    it('should print criterion correctly', () => {
        const dateMin = '2019-02-08';
        const dateMax = '2019-02-17';
        const criterion = new BetweenCriterion(1, dateMin, dateMax);
        const expectedPrintedCriterion = '∈ [' + dateMin + ';' + dateMax + ']';
        expect(criterion.printCriterion()).toEqual(expectedPrintedCriterion);
        const criterionMin = new BetweenCriterion(1, dateMin, '');
        const expectedPrintedCriterionMin = '>= ' + dateMin;
        expect(criterionMin.printCriterion()).toEqual(expectedPrintedCriterionMin);
        const criterionMax = new BetweenCriterion(1, '', dateMax);
        const expectedPrintedCriterionMax = '<= ' + dateMax;
        expect(criterionMax.printCriterion()).toEqual(expectedPrintedCriterionMax);
    });

    it('should print criterion url string correctly', () => {
        const id = 1;
        const dateMin = '2019-02-08';
        const dateMax = '2019-02-17';
        const criterion = new BetweenCriterion(id, dateMin, dateMax);
        const expectedPrintedCriterion = id + '::bw::' + dateMin + '|' + dateMax;
        expect(criterion.getCriterionStr()).toEqual(expectedPrintedCriterion);
    });
});