fradrive/frontend/src/utils/async-table/async-table.spec.js
2020-05-05 15:16:42 +02:00

54 lines
1.2 KiB
JavaScript

import { AsyncTable } from './async-table';
const AppTestMock = {
httpClient: {
get: () => {},
},
htmlHelpers: {
parseResponse: () => {},
},
utilRegistry: {
initAll: () => {},
},
};
describe('AsyncTable', () => {
let asyncTable;
beforeEach(() => {
const element = document.createElement('div');
const scrollTable = document.createElement('div');
const table = document.createElement('table');
table.id = 'ident';
scrollTable.classList.add('scrolltable');
scrollTable.appendChild(table);
element.appendChild(scrollTable);
asyncTable = new AsyncTable(element, AppTestMock);
});
it('should create', () => {
expect(asyncTable).toBeTruthy();
});
it('should throw if element does not contain a .scrolltable', () => {
const element = document.createElement('div');
expect(() => {
new AsyncTable(element, AppTestMock);
}).toThrow();
});
it('should throw if element does not contain a table', () => {
const element = document.createElement('div');
expect(() => {
new AsyncTable(element, AppTestMock);
}).toThrow();
});
it('should throw if called without an element', () => {
expect(() => {
new AsyncTable();
}).toThrow();
});
});