diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-05 06:11:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 11:11:08 +0000 |
commit | 71c3aff53173cc83a96d7d2715b7918bdbc2d8a5 (patch) | |
tree | d13cc4a90ef26bb6476daca1edc1999208f4fadc /dev/lib/handlebars/src/spec/index.strict.test.ts | |
parent | 0e7531bc5b443461d7e76e20877464ccf48a3ef5 (diff) |
kbn-handlebars dependency update (#613)
* Update kbn-handlebars dependency
* Move handlebars dependency to dev
* Update package
* Update readme
* Update readme
* Ignore legal file
Diffstat (limited to 'dev/lib/handlebars/src/spec/index.strict.test.ts')
-rw-r--r-- | dev/lib/handlebars/src/spec/index.strict.test.ts | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/dev/lib/handlebars/src/spec/index.strict.test.ts b/dev/lib/handlebars/src/spec/index.strict.test.ts deleted file mode 100644 index a8f294b9..00000000 --- a/dev/lib/handlebars/src/spec/index.strict.test.ts +++ /dev/null @@ -1,164 +0,0 @@ -/* - * This file is forked from the handlebars project (https://github.com/handlebars-lang/handlebars.js), - * and may include modifications made by Elasticsearch B.V. - * Elasticsearch B.V. licenses this file to you under the MIT License. - * See `packages/kbn-handlebars/LICENSE` for more information. - */ - -import { expectTemplate } from '../__jest__/test_bench'; - -describe('strict', () => { - describe('strict mode', () => { - it('should error on missing property lookup', () => { - expectTemplate('{{hello}}') - .withCompileOptions({ strict: true }) - .toThrow(/"hello" not defined in/); - }); - - it('should error on missing child', () => { - expectTemplate('{{hello.bar}}') - .withCompileOptions({ strict: true }) - .withInput({ hello: { bar: 'foo' } }) - .toCompileTo('foo'); - - expectTemplate('{{hello.bar}}') - .withCompileOptions({ strict: true }) - .withInput({ hello: {} }) - .toThrow(/"bar" not defined in/); - }); - - it('should handle explicit undefined', () => { - expectTemplate('{{hello.bar}}') - .withCompileOptions({ strict: true }) - .withInput({ hello: { bar: undefined } }) - .toCompileTo(''); - }); - - it('should error on missing property lookup in known helpers mode', () => { - expectTemplate('{{hello}}') - .withCompileOptions({ - strict: true, - knownHelpersOnly: true, - }) - .toThrow(/"hello" not defined in/); - }); - - it('should error on missing context', () => { - expectTemplate('{{hello}}').withCompileOptions({ strict: true }).toThrow(Error); - }); - - it('should error on missing data lookup', () => { - const xt = expectTemplate('{{@hello}}').withCompileOptions({ - strict: true, - }); - - xt.toThrow(Error); - - xt.withRuntimeOptions({ data: { hello: 'foo' } }).toCompileTo('foo'); - }); - - it('should not run helperMissing for helper calls', () => { - expectTemplate('{{hello foo}}') - .withCompileOptions({ strict: true }) - .withInput({ foo: true }) - .toThrow(/"hello" not defined in/); - - expectTemplate('{{#hello foo}}{{/hello}}') - .withCompileOptions({ strict: true }) - .withInput({ foo: true }) - .toThrow(/"hello" not defined in/); - }); - - it('should throw on ambiguous blocks', () => { - expectTemplate('{{#hello}}{{/hello}}') - .withCompileOptions({ strict: true }) - .toThrow(/"hello" not defined in/); - - expectTemplate('{{^hello}}{{/hello}}') - .withCompileOptions({ strict: true }) - .toThrow(/"hello" not defined in/); - - expectTemplate('{{#hello.bar}}{{/hello.bar}}') - .withCompileOptions({ strict: true }) - .withInput({ hello: {} }) - .toThrow(/"bar" not defined in/); - }); - - it('should allow undefined parameters when passed to helpers', () => { - expectTemplate('{{#unless foo}}success{{/unless}}') - .withCompileOptions({ strict: true }) - .toCompileTo('success'); - }); - - it('should allow undefined hash when passed to helpers', () => { - expectTemplate('{{helper value=@foo}}') - .withCompileOptions({ - strict: true, - }) - .withHelpers({ - helper(options) { - expect('value' in options.hash).toEqual(true); - expect(options.hash.value).toBeUndefined(); - return 'success'; - }, - }) - .toCompileTo('success'); - }); - - it('should show error location on missing property lookup', () => { - expectTemplate('\n\n\n {{hello}}') - .withCompileOptions({ strict: true }) - .toThrow('"hello" not defined in [object Object] - 4:5'); - }); - - it('should error contains correct location properties on missing property lookup', () => { - try { - expectTemplate('\n\n\n {{hello}}') - .withCompileOptions({ strict: true }) - .toCompileTo('throw before asserting this'); - } catch (error) { - expect(error.lineNumber).toEqual(4); - expect(error.endLineNumber).toEqual(4); - expect(error.column).toEqual(5); - expect(error.endColumn).toEqual(10); - } - }); - }); - - describe('assume objects', () => { - it('should ignore missing property', () => { - expectTemplate('{{hello}}').withCompileOptions({ assumeObjects: true }).toCompileTo(''); - }); - - it('should ignore missing child', () => { - expectTemplate('{{hello.bar}}') - .withCompileOptions({ assumeObjects: true }) - .withInput({ hello: {} }) - .toCompileTo(''); - }); - - it('should error on missing object', () => { - expectTemplate('{{hello.bar}}').withCompileOptions({ assumeObjects: true }).toThrow(Error); - }); - - it('should error on missing context', () => { - expectTemplate('{{hello}}') - .withCompileOptions({ assumeObjects: true }) - .withInput(undefined) - .toThrow(Error); - }); - - it('should error on missing data lookup', () => { - expectTemplate('{{@hello.bar}}') - .withCompileOptions({ assumeObjects: true }) - .withInput(undefined) - .toThrow(Error); - }); - - it('should execute blockHelperMissing', () => { - expectTemplate('{{^hello}}foo{{/hello}}') - .withCompileOptions({ assumeObjects: true }) - .toCompileTo('foo'); - }); - }); -}); |