mirror of
https://github.com/directus/directus.git
synced 2026-01-29 14:48:02 -05:00
76 lines
1.9 KiB
TypeScript
76 lines
1.9 KiB
TypeScript
import { functions } from '../../src/utils/functions';
|
|
|
|
describe('Data Functions', () => {
|
|
describe('year', () => {
|
|
it('Returns the year from a given ISO string', () => {
|
|
const input = '2022-03-30T13:44:49.166Z';
|
|
const output = functions.year(input);
|
|
expect(output).toBe(2022);
|
|
});
|
|
});
|
|
|
|
describe('month', () => {
|
|
it('Returns the month from a given ISO string', () => {
|
|
const input = '2022-03-30T13:44:49.166Z';
|
|
const output = functions.month(input);
|
|
expect(output).toBe(3);
|
|
});
|
|
});
|
|
|
|
describe('week', () => {
|
|
it('Returns the week from a given ISO string', () => {
|
|
const input = '2022-03-30T13:44:49.166Z';
|
|
const output = functions.week(input);
|
|
expect(output).toBe(14);
|
|
});
|
|
});
|
|
|
|
describe('day', () => {
|
|
it('Returns the day from a given ISO string', () => {
|
|
const input = '2022-03-30T13:44:49.166Z';
|
|
const output = functions.day(input);
|
|
expect(output).toBe(30);
|
|
});
|
|
});
|
|
|
|
describe('weekday', () => {
|
|
it('Returns the weekday from a given ISO string', () => {
|
|
const input = '2022-03-30T13:44:49.166Z';
|
|
const output = functions.weekday(input);
|
|
expect(output).toBe(3);
|
|
});
|
|
});
|
|
|
|
describe('hour', () => {
|
|
it('Returns the hour from a given ISO string', () => {
|
|
const input = '2022-03-30T13:44:49.166+0200';
|
|
const output = functions.hour(input);
|
|
expect(output).toBe(11);
|
|
});
|
|
});
|
|
|
|
describe('minute', () => {
|
|
it('Returns the minute from a given ISO string', () => {
|
|
const input = '2022-03-30T13:44:49.166Z';
|
|
const output = functions.minute(input);
|
|
expect(output).toBe(44);
|
|
});
|
|
});
|
|
|
|
describe('second', () => {
|
|
it('Returns the second from a given ISO string', () => {
|
|
const input = '2022-03-30T13:44:49.166Z';
|
|
const output = functions.second(input);
|
|
expect(output).toBe(49);
|
|
});
|
|
});
|
|
|
|
describe('count', () => {
|
|
it('Returns the length of a given array', () => {
|
|
const input = ['a', 'b', 'c'];
|
|
const output = functions.count(input);
|
|
expect(output).toBe(3);
|
|
});
|
|
});
|
|
});
|