Home Manual Reference Source Test Repository

test/unit/filter/future-date.spec.js

import assert from 'assert';

import futureDate from '../../../lib/filter/future-date';

describe('filter/future-date futureDate', () => {
  it('should default to use date as key value', () => {
    assert.equal(
      futureDate({
        data: {
          date: Date.now() - 1000,
        },
      }),
      false
    );

    assert.equal(
      futureDate({
        data: {
          date: Date.now() + 1000,
        },
      }),
      true
    );

    assert.equal(
      futureDate({
        data: {
          dateKey: Date.now() + 1000,
        },
      }),
      false
    );
  });

  it('should allow setting of what date key to use', () => {
    assert.equal(
      futureDate(
        {
          data: {
            whee: Date.now() - 1000,
          },
        },
        { key: 'whee' }
      ),
      false
    );

    assert.equal(
      futureDate(
        {
          data: {
            whee: Date.now() + 1000,
          },
        },
        { key: 'whee' }
      ),
      true
    );

    assert.equal(
      futureDate(
        {
          data: {
            date: Date.now() + 1000,
          },
        },
        { key: 'whee' }
      ),
      false
    );
  });
});