Add unit tests for `query-history-info`

This commit is contained in:
shati-patel 2022-10-14 16:39:26 +01:00
Родитель 38caad032b
Коммит 60e9f552db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1294A07B85CE9116
1 изменённых файлов: 43 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,43 @@
import { expect } from 'chai';
import { QueryStatus } from '../../src/query-status';
import { getRawQueryName } from '../../src/query-history-info';
import { VariantAnalysisHistoryItem } from '../../src/remote-queries/variant-analysis-history-item';
import { createMockVariantAnalysis } from '../../src/vscode-tests/factories/remote-queries/shared/variant-analysis';
import { createMockLocalQueryInfo } from '../../src/vscode-tests/factories/local-queries/local-query-history-item';
import { createMockRemoteQueryHistoryItem } from '../../src/vscode-tests/factories/remote-queries/remote-query-history-item';
describe('Query history info', () => {
describe('getRawQueryName', () => {
it('should get the name for local history items', () => {
const date = new Date('2022-01-01T00:00:00.000Z');
const dateStr = date.toLocaleString();
const queryHistoryItem = createMockLocalQueryInfo(dateStr);
const queryName = getRawQueryName(queryHistoryItem);
expect(queryName).to.equal(queryHistoryItem.getQueryName());
});
it('should get the name for remote query history items', () => {
const queryHistoryItem = createMockRemoteQueryHistoryItem({});
const queryName = getRawQueryName(queryHistoryItem);
expect(queryName).to.equal(queryHistoryItem.remoteQuery.queryName);
});
it('should get the name for variant analysis history items', () => {
const queryHistoryItem: VariantAnalysisHistoryItem = {
t: 'variant-analysis',
status: QueryStatus.InProgress,
completed: false,
variantAnalysis: createMockVariantAnalysis()
};
const queryName = getRawQueryName(queryHistoryItem);
expect(queryName).to.equal(queryHistoryItem.variantAnalysis.query.name);
});
});
});