add unit test for main frontend application
This commit is contained in:
parent
c98c370317
commit
6d3385aa88
52
frontend/src/app.spec.js
Normal file
52
frontend/src/app.spec.js
Normal file
@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user