|
| 1 | +describe('engine-test', function() { |
| 2 | + /*********************** |
| 3 | + * Engine::Engine::run * |
| 4 | + ***********************/ |
| 5 | + it('should throw an exception if the abstract method `run` is called', function() { |
| 6 | + e = new window.JsWidget.Engine.Engine(); |
| 7 | + |
| 8 | + expect(e.run).to.throw(Error, 'Not implemented. The method `run` can\'t be called on the Engine class. Please use a concrete engine.'); |
| 9 | + }); |
| 10 | + |
| 11 | + /******************************** |
| 12 | + * Engine::Engine::check_engine * |
| 13 | + ********************************/ |
| 14 | + it('check_engine doesn\'t throw an exception for engine `handlebars` if handlebars is installed', function() { |
| 15 | + e = new window.JsWidget.Engine.Handlebars(); |
| 16 | + window.JsWidget.EnginePresence = ['handlebars']; |
| 17 | + |
| 18 | + expect(e.check_engine).to.not.throw(Error); |
| 19 | + }); |
| 20 | + |
| 21 | + it('check_engine throws an exception for engine `handlebars` if handlebars isn\'t installed', function() { |
| 22 | + e = new window.JsWidget.Engine.Handlebars(); |
| 23 | + window.JsWidget.EnginePresence = []; |
| 24 | + |
| 25 | + expect(e.check_engine).to.throw(Error, 'Template Engine \'handlebars\' is missing. Please install the template engine you want to use and try again'); |
| 26 | + }); |
| 27 | + |
| 28 | + it('check_engine doesn\'t throw an exception for engine `jquery` if jquery-templating is installed', function() { |
| 29 | + e = new window.JsWidget.Engine.JQuery(); |
| 30 | + window.JsWidget.EnginePresence = ['jquery-templating']; |
| 31 | + |
| 32 | + expect(e.check_engine).to.not.throw(Error); |
| 33 | + }); |
| 34 | + |
| 35 | + it('check_engine throws an exception for engine `jquery` if jquery-templating isn\'t installed', function() { |
| 36 | + e = new window.JsWidget.Engine.JQuery(); |
| 37 | + window.JsWidget.EnginePresence = []; |
| 38 | + |
| 39 | + expect(e.check_engine).to.throw(Error, 'Template Engine \'jquery-templating\' is missing. Please install the template engine you want to use and try again'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('check_engine doesn\'t throw an exception for engine `mustache` if mustache is installed', function() { |
| 43 | + e = new window.JsWidget.Engine.Mustache(); |
| 44 | + window.JsWidget.EnginePresence = ['mustache']; |
| 45 | + |
| 46 | + expect(e.check_engine).to.not.throw(Error); |
| 47 | + }); |
| 48 | + |
| 49 | + it('check_engine throws an exception for engine `mustache` if mustache isn\'t installed', function() { |
| 50 | + e = new window.JsWidget.Engine.Mustache(); |
| 51 | + window.JsWidget.EnginePresence = []; |
| 52 | + |
| 53 | + expect(e.check_engine).to.throw(Error, 'Template Engine \'mustache\' is missing. Please install the template engine you want to use and try again'); |
| 54 | + }); |
| 55 | + |
| 56 | + it('check_engine doesn\'t throw an exception for engine `underscore` if underscore.js is installed', function() { |
| 57 | + e = new window.JsWidget.Engine.Underscore(); |
| 58 | + window.JsWidget.EnginePresence = ['underscore.js']; |
| 59 | + |
| 60 | + expect(e.check_engine).to.not.throw(Error); |
| 61 | + }); |
| 62 | + |
| 63 | + it('check_engine throws an exception for engine `underscore` if underscore.js isn\'t installed', function() { |
| 64 | + e = new window.JsWidget.Engine.Underscore(); |
| 65 | + window.JsWidget.EnginePresence = []; |
| 66 | + |
| 67 | + expect(e.check_engine).to.throw(Error, 'Template Engine \'underscore.js\' is missing. Please install the template engine you want to use and try again'); |
| 68 | + }); |
| 69 | +}); |
0 commit comments