From 94a19e14b8cd54d1dc5e0c500ac838a300e048da Mon Sep 17 00:00:00 2001 From: shadowtime2000 <66655515+shadowtime2000@users.noreply.github.com> Date: Sat, 5 Dec 2020 13:36:24 -0800 Subject: [PATCH] test: refactor let into const --- test/config.spec.ts | 2 +- test/file-handlers.spec.ts | 2 +- test/file-utils.spec.ts | 10 +++++----- test/render.spec.ts | 20 ++++++++++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/config.spec.ts b/test/config.spec.ts index 4cfb9ef..f0bb4de 100644 --- a/test/config.spec.ts +++ b/test/config.spec.ts @@ -20,7 +20,7 @@ describe('Config Tests', () => { }) it('config.filter works', () => { - let template = 'My favorite food is <%= it.fav %>' + const template = 'My favorite food is <%= it.fav %>' expect(render(template, {})).toEqual('My favorite food is undefined') diff --git a/test/file-handlers.spec.ts b/test/file-handlers.spec.ts index 7867c93..fc22d69 100644 --- a/test/file-handlers.spec.ts +++ b/test/file-handlers.spec.ts @@ -91,7 +91,7 @@ describe('Simple renderFile tests', () => { describe('File location tests', () => { it('locates a file with the views option', async () => { - let res = await renderFile( + const res = await renderFile( 'simple.eta', { name: 'Ada' }, { views: path.join(__dirname, 'templates') } diff --git a/test/file-utils.spec.ts b/test/file-utils.spec.ts index 7603d76..50087d0 100644 --- a/test/file-utils.spec.ts +++ b/test/file-utils.spec.ts @@ -19,9 +19,9 @@ describe('Filepath caching', () => { // This test renders templates/has-include.eta with caching enabled, then checks to make sure // `config.filepathCache` contains the expected result afterward - let viewsDir = path.join(__dirname, 'templates') + const viewsDir = path.join(__dirname, 'templates') - let templateResult = await renderFile('has-include', {}, { views: viewsDir, cache: true }) + const templateResult = await renderFile('has-include', {}, { views: viewsDir, cache: true }) expect(templateResult).toEqual( `This is the outermost template. Now we'll include a partial @@ -36,11 +36,11 @@ Hi Test Runner` // Filepath caching is based on the premise that given the same path, includer filename, root directory, and views directory (or directories) // the getPath function will always return the same result (assuming that caching is enabled and we're not expecting the templates to change) - let pathToHasInclude = `{"filename":"${viewsDir}/has-include.eta","path":"./partial","views":"${viewsDir}"}` + const pathToHasInclude = `{"filename":"${viewsDir}/has-include.eta","path":"./partial","views":"${viewsDir}"}` - let pathToPartial = `{"filename":"${viewsDir}/partial.eta","path":"./simple","views":"${viewsDir}"}` + const pathToPartial = `{"filename":"${viewsDir}/partial.eta","path":"./simple","views":"${viewsDir}"}` - let pathToSimple = `{"path":"has-include","views":"${viewsDir}"}` + const pathToSimple = `{"path":"has-include","views":"${viewsDir}"}` expect(config.filepathCache).toEqual({ [pathToHasInclude]: `${viewsDir}/partial.eta`, diff --git a/test/render.spec.ts b/test/render.spec.ts index f6a2a2e..08e2da2 100644 --- a/test/render.spec.ts +++ b/test/render.spec.ts @@ -21,7 +21,7 @@ describe('Simple Render checks', () => { }) it('Rendering function works', async () => { const template = 'Hello <%= await it.getName() %>!' - let getName = () => { + const getName = () => { return new Promise((res) => { setTimeout(() => { res('Ada') @@ -32,7 +32,7 @@ describe('Simple Render checks', () => { }) it('Rendering async function works', async () => { const template = 'Hello <%= await it.getName() %>!' - let getName = () => { + const getName = () => { return new Promise((res) => { setTimeout(() => { res('Ada') @@ -67,15 +67,15 @@ describe('Renders with different scopes', () => { describe('processTemplate plugin', () => { it('Simple plugin works correctly', () => { - let template = ':thumbsup:' + const template = ':thumbsup:' - let emojiTransform = { + const emojiTransform = { processTemplate: function (str: string) { return str.replace(':thumbsup:', '👍') } } - let res = render( + const res = render( template, {}, { @@ -87,27 +87,27 @@ describe('processTemplate plugin', () => { }) it('Multiple chained plugins work correctly', () => { - let template = ':thumbsup: This is a cool template' + const template = ':thumbsup: This is a cool template' - let emojiTransform = { + const emojiTransform = { processTemplate: function (str: string) { return str.replace(':thumbsup:', '👍') } } - let capitalizeCool = { + const capitalizeCool = { processTemplate: function (str: string) { return str.replace('cool', 'COOL') } } - let replaceThumbsUp = { + const replaceThumbsUp = { processTemplate: function (str: string) { return str.replace('👍', '✨') } } - let res = render( + const res = render( template, {}, {