diff --git a/frontend/src/app.spec.js b/frontend/src/app.spec.js new file mode 100644 index 000000000..8ce962b2d --- /dev/null +++ b/frontend/src/app.spec.js @@ -0,0 +1,52 @@ +import { App } from "./app"; + +const TEST_UTILS = [ + { name: 'util1' }, + { name: 'util2' }, +]; + +describe('App', () => { + let app; + + beforeEach(() => { + app = new App(); + }); + + it('should create', () => { + expect(app).toBeTruthy(); + }); + + describe('provides services', () => { + it('HttpClient as httpClient', () => { + expect(app.httpClient).toBeTruthy(); + }); + + it('HtmlHelpers as htmlHelpers', () => { + expect(app.htmlHelpers).toBeTruthy(); + }); + + it('I18n as i18n', () => { + expect(app.i18n).toBeTruthy(); + }); + + it('UtilRegistry as utilRegistry', () => { + expect(app.utilRegistry).toBeTruthy(); + }); + }); + + describe('registerUtilities()', () => { + it('should register the given utilities', () => { + spyOn(app.utilRegistry, 'register'); + app.registerUtilities(TEST_UTILS); + expect(app.utilRegistry.register.calls.count()).toBe(TEST_UTILS.length); + expect(app.utilRegistry.register.calls.argsFor(0)).toEqual([TEST_UTILS[0]]); + expect(app.utilRegistry.register.calls.argsFor(1)).toEqual([TEST_UTILS[1]]); + }); + + it('should throw an error if not passed an array of utilities', () => { + expect(() => { + app.registerUtilities({}); + }).toThrow(); + }); + }); +});