Skip to content

Commit

Permalink
Merge pull request #82 from jaredwray/adding-in-year-helper-testing
Browse files Browse the repository at this point in the history
adding in year helper tests
  • Loading branch information
jaredwray authored Dec 15, 2024
2 parents ce7dffd + 44c1820 commit e426fa8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/helpers/date.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {describe, it, expect} from 'vitest';
import {helpers} from '../../src/helpers/date.js';

describe('helpers', () => {
it('should have a "year" helper with the correct properties', () => {
// Find the 'year' helper in the array
const yearHelper = helpers.find(helper => helper.name === 'year');

// Assert the helper is defined
expect(yearHelper).toBeDefined();

// Assert the helper has the correct properties
expect(yearHelper?.name).toBe('year');
expect(yearHelper?.category).toBe('date');
expect(typeof yearHelper?.fn).toBe('function');
});

it('should return the current year as a string when the "year" helper function is invoked', () => {
// Find the 'year' helper
const yearHelper = helpers.find(helper => helper.name === 'year');
expect(yearHelper).toBeDefined();

// Invoke the function
const currentYear = new Date().getFullYear().toString();
expect(yearHelper?.fn()).toBe(currentYear);
});
});

0 comments on commit e426fa8

Please sign in to comment.