UNPKG

@unchainedshop/plugins

Version:

Because of a Typescript issue with upstream "postfinancecheckout", the Postfinance plugin has been disabled from transpilation, import the source ts files from src and enable node_module tsc or copy over the src/payment/postfinance-checkout to your projec

39 lines (32 loc) 1.35 kB
import { describe, it } from 'node:test'; import assert from 'node:assert'; import { rangeMatcher } from '../enrollments/licensed.js'; describe('rangeMatcher', () => { const now = new Date(); const tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); const tomorrowTimestamp = tomorrow.getTime(); const yesterday = new Date(); yesterday.setDate(yesterday.getDate() - 1); const yesterdayTimestamp = yesterday.getTime(); it('matches correctly when the date is within the range', () => { const range = { start: yesterday, end: tomorrow }; const matcher = rangeMatcher(now); assert.strictEqual(matcher(range), true); }); it('does not match when the date is before the start of the range', () => { const range = { start: tomorrow, end: tomorrow }; const matcher = rangeMatcher(yesterday); assert.strictEqual(matcher(range), false); }); it('does not match when the date is after the end of the range', () => { const range = { start: yesterday, end: yesterday }; const matcher = rangeMatcher(tomorrow); assert.strictEqual(matcher(range), false); }); it('matches correctly when the date is not provided', () => { const range = { start: yesterdayTimestamp, end: tomorrowTimestamp }; const matcher = rangeMatcher(); assert.strictEqual(matcher(range), true); }); });