From ad0b5e758311de5938375b390f9ba4f7584b6d8b Mon Sep 17 00:00:00 2001 From: Benedict Aas Date: Wed, 7 Feb 2018 11:47:16 +0000 Subject: [PATCH] test modal --- tests/gui/components/modal.spec.js | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/gui/components/modal.spec.js diff --git a/tests/gui/components/modal.spec.js b/tests/gui/components/modal.spec.js new file mode 100644 index 00000000..7880e15b --- /dev/null +++ b/tests/gui/components/modal.spec.js @@ -0,0 +1,40 @@ + +const m = require('mochainon') + +describe('Browser: Modal', function () { + beforeEach(angular.mock.module( + require('../../../lib/gui/app/components/modal/modal') + )) + + describe('ModalService', function () { + let ModalService + + beforeEach(angular.mock.inject(function (_ModalService_) { + ModalService = _ModalService_ + })) + + describe('.open()', function () { + it('should not emit any errors when the template is a non-empty string', function () { + m.chai.expect(function () { + ModalService.open({ + template: '
{{ \'Hello\' }}, World!
' + }) + }).to.not.throw() + }) + + it('should emit error on no template field', function () { + m.chai.expect(function () { + ModalService.open({}) + }).to.throw('One of component or template or templateUrl options is required.') + }) + + it('should emit error on empty string template', function () { + m.chai.expect(function () { + ModalService.open({ + template: '' + }) + }).to.throw('One of component or template or templateUrl options is required.') + }) + }) + }) +})