diff --git a/lib/shops.ts b/lib/shops.ts index 1a09970..60555a7 100644 --- a/lib/shops.ts +++ b/lib/shops.ts @@ -18,7 +18,7 @@ const closed: Record = { * Returns the shop status for the given date. * @param date */ -export function getShopStatus(date: DateTime): string { +export function getShopsStatus(date: DateTime): string { // Easter Monday if (isEasterMonday(date)) { return "zavřeno"; @@ -37,6 +37,6 @@ export function getShopStatus(date: DateTime): string { * Returns true if the given date is a shop open day. * @param date */ -export function isOpen(date: DateTime): boolean { - return getShopStatus(date).startsWith("otevřeno") +export function areShopsOpen(date: DateTime): boolean { + return getShopsStatus(date).startsWith("otevřeno") } \ No newline at end of file diff --git a/test/shops.ts b/test/shops.ts index e934877..4208866 100644 --- a/test/shops.ts +++ b/test/shops.ts @@ -1,31 +1,31 @@ import test from 'ava'; import {DateTime} from "luxon"; -import {getShopStatus, isOpen} from "../lib/shops.js"; +import {getShopsStatus, areShopsOpen} from "../lib/shops.js"; test('Check shops open/close status', t => { - t.is(getShopStatus(DateTime.fromISO('2024-12-25')), 'zavřeno'); - t.is(getShopStatus(DateTime.fromISO('2024-12-26')), 'zavřeno'); - t.is(getShopStatus(DateTime.fromISO('2024-05-01')), 'otevřeno'); + t.is(getShopsStatus(DateTime.fromISO('2024-12-25')), 'zavřeno'); + t.is(getShopsStatus(DateTime.fromISO('2024-12-26')), 'zavřeno'); + t.is(getShopsStatus(DateTime.fromISO('2024-05-01')), 'otevřeno'); }); test('Check if Easter Monday is closed and Friday is not', t => { - t.is(getShopStatus(DateTime.fromISO('2024-03-28')), 'otevřeno'); // Friday - t.is(getShopStatus(DateTime.fromISO('2024-04-01')), 'zavřeno'); // Monday + t.is(getShopsStatus(DateTime.fromISO('2024-03-28')), 'otevřeno'); // Friday + t.is(getShopsStatus(DateTime.fromISO('2024-04-01')), 'zavřeno'); // Monday }) test('Check if Christmas Eve is open until noon', t => { - t.is(getShopStatus(DateTime.fromISO('2024-12-24')), 'otevřeno do 12:00'); - t.is(getShopStatus(DateTime.fromISO('2025-12-24')), 'otevřeno do 12:00'); + t.is(getShopsStatus(DateTime.fromISO('2024-12-24')), 'otevřeno do 12:00'); + t.is(getShopsStatus(DateTime.fromISO('2025-12-24')), 'otevřeno do 12:00'); }) test('Check if shops are open or closed', t => { // open days - t.true(isOpen(DateTime.fromISO('2024-12-24'))); // Christmas Eve is open until noon - t.true(isOpen(DateTime.fromISO('2024-05-01'))); // Labour Day - t.true(isOpen(DateTime.fromISO('2024-11-17'))); // Struggle for Freedom and Democracy Day + t.true(areShopsOpen(DateTime.fromISO('2024-12-24'))); // Christmas Eve is open until noon + t.true(areShopsOpen(DateTime.fromISO('2024-05-01'))); // Labour Day + t.true(areShopsOpen(DateTime.fromISO('2024-11-17'))); // Struggle for Freedom and Democracy Day // closed days - t.false(isOpen(DateTime.fromISO('2024-01-01'))); - t.false(isOpen(DateTime.fromISO('2024-12-26'))); + t.false(areShopsOpen(DateTime.fromISO('2024-01-01'))); + t.false(areShopsOpen(DateTime.fromISO('2024-12-26'))); });