|
| 1 | +/*globals Handlebars, shouldThrow */ |
| 2 | + |
| 3 | +describe('runtime', function() { |
| 4 | + describe('#template', function() { |
| 5 | + it('should throw on invalid templates', function() { |
| 6 | + shouldThrow(function() { |
| 7 | + Handlebars.template({}); |
| 8 | + }, Error, 'Unknown template object: object'); |
| 9 | + shouldThrow(function() { |
| 10 | + Handlebars.template(); |
| 11 | + }, Error, 'Unknown template object: undefined'); |
| 12 | + shouldThrow(function() { |
| 13 | + Handlebars.template(''); |
| 14 | + }, Error, 'Unknown template object: string'); |
| 15 | + }); |
| 16 | + it('should throw on version mismatch', function() { |
| 17 | + shouldThrow(function() { |
| 18 | + Handlebars.template({ |
| 19 | + main: true, |
| 20 | + compiler: [Handlebars.COMPILER_REVISION + 1] |
| 21 | + }); |
| 22 | + }, Error, /Template was precompiled with a newer version of Handlebars than the current runtime/); |
| 23 | + shouldThrow(function() { |
| 24 | + Handlebars.template({ |
| 25 | + main: true, |
| 26 | + compiler: [Handlebars.COMPILER_REVISION - 1] |
| 27 | + }); |
| 28 | + }, Error, /Template was precompiled with an older version of Handlebars than the current runtime/); |
| 29 | + shouldThrow(function() { |
| 30 | + Handlebars.template({ |
| 31 | + main: true |
| 32 | + }); |
| 33 | + }, Error, /Template was precompiled with an older version of Handlebars than the current runtime/); |
| 34 | + }); |
| 35 | + }); |
| 36 | +}); |
0 commit comments