Skip to content

Commit

Permalink
Merge pull request #75 from jaredwray/adding-in-tests-to-make-sure-it…
Browse files Browse the repository at this point in the history
…-has-or-doesnt-have-helpers

adding in tests to make sure it has or doesnt have helpers
  • Loading branch information
jaredwray authored Dec 2, 2024
2 parents 67a427e + 6ed8117 commit 62921d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ We plan to make significant changes over time with this project such as the foll
Because of the complexity in the legacy helpers library we have moved to exporting the libraries and a helper function to make it easier to use. Here are the exports:

- `handlebars` - This is an instance of handlebars library without any helpers. It is the same as calling `Handlebars.create()`
- `helpers` - This is a function that takes an object with a `handlebars` key and adds all the helpers to the handlebars instance. This is the same as calling `helpers({ handlebars: handlebars })`
- `createHandlebars` - This is an async function that returns a handlebars instance with all the helpers added. This is the same as calling `helpers({ handlebars: handlebars })` but async.
- `helpers` - This is a function that takes an object with a `handlebars` key and adds all the helpers to the handlebars instance. This is the same as calling `helpers({ handlebars: handlebars }, { ..options })`
- `createHandlebars` - This is an async function that returns a handlebars instance with all the helpers added. This is the same as calling `helpers({ handlebars: handlebars }, { ..options })` but async.
- `Handlebars` - This is the handlebars library itself. It is the same as calling `require('handlebars')`

Please see the examples below for how to use the library.
Expand Down
12 changes: 12 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@ describe('fumanchu', () => {

test('should have handlebars', () => {
expect(handlebars).toBeDefined();
const result = handlebars.compile('{{year}}');
expect(result({})).toBe('');
});

test('should be able to createHandlebars', async () => {
const handlebars = await createHandlebars();
expect(handlebars).toBeDefined();
const result = handlebars.compile('{{year}}');
expect(result({})).toBe(new Date().getFullYear().toString());
});

test('should be able to run fumanchu()', () => {
const handlebars = fumanchu();
expect(handlebars).toBeDefined();
const result = handlebars.compile('{{year}}');
expect(result({})).toBe(new Date().getFullYear().toString());
});

test('should be able to set helpers', async () => {
helpers({handlebars});
const result = handlebars.compile('{{year}}');
expect(result({})).toBe(new Date().getFullYear().toString());
});
});

0 comments on commit 62921d5

Please sign in to comment.