From 6ed8117e881fc8700ad7d54f9ec1f222bd20f75a Mon Sep 17 00:00:00 2001 From: Jared Wray Date: Mon, 2 Dec 2024 09:14:14 -0800 Subject: [PATCH] adding in tests to make sure it has or doesnt have helpers --- README.md | 4 ++-- test/index.test.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6af7eb1..a51ec09 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/test/index.test.ts b/test/index.test.ts index c1134de..323fccd 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -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()); }); });