mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* tech: investigating karma + jest mix * tech: migrating tests to jest * tech: moved anoter test file to jest * test: migrated two more test files to jest * test: updated readme and made test fail to verify that it causes CI build failure * tech: added code coverage for jest tests * tech: testing codecov coverage * tech: migrated more tests * tech: migrated template srv to typescript and the tests to jest * tech: minor build fix * tech: build fixes * build: another attempt at fixing go test with coverage
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import TableModel from 'app/core/table_model';
|
|
|
|
describe('when sorting table desc', () => {
|
|
var table;
|
|
var panel = {
|
|
sort: {col: 0, desc: true},
|
|
};
|
|
|
|
beforeEach(() => {
|
|
table = new TableModel();
|
|
table.columns = [{}, {}];
|
|
table.rows = [[100, 12], [105, 10], [103, 11]];
|
|
table.sort(panel.sort);
|
|
});
|
|
|
|
it('should sort by time', () => {
|
|
expect(table.rows[0][0]).toBe(105);
|
|
expect(table.rows[1][0]).toBe(103);
|
|
expect(table.rows[2][0]).toBe(100);
|
|
});
|
|
|
|
it ('should mark column being sorted', () => {
|
|
expect(table.columns[0].sort).toBe(true);
|
|
expect(table.columns[0].desc).toBe(true);
|
|
});
|
|
|
|
});
|
|
|
|
describe('when sorting table asc', () => {
|
|
var table;
|
|
var panel = {
|
|
sort: {col: 1, desc: false},
|
|
};
|
|
|
|
beforeEach(() => {
|
|
table = new TableModel();
|
|
table.columns = [{}, {}];
|
|
table.rows = [[100, 11], [105, 15], [103, 10]];
|
|
table.sort(panel.sort);
|
|
});
|
|
|
|
it('should sort by time', () => {
|
|
expect(table.rows[0][1]).toBe(10);
|
|
expect(table.rows[1][1]).toBe(11);
|
|
expect(table.rows[2][1]).toBe(15);
|
|
});
|
|
|
|
});
|
|
|