|
| 1 | +import { expect } from 'chai'; |
| 2 | + |
| 3 | +import { QueryStatus } from '../../src/query-status'; |
| 4 | +import { getRawQueryName } from '../../src/query-history-info'; |
| 5 | +import { VariantAnalysisHistoryItem } from '../../src/remote-queries/variant-analysis-history-item'; |
| 6 | +import { createMockVariantAnalysis } from '../../src/vscode-tests/factories/remote-queries/shared/variant-analysis'; |
| 7 | +import { createMockLocalQueryInfo } from '../../src/vscode-tests/factories/local-queries/local-query-history-item'; |
| 8 | +import { createMockRemoteQueryHistoryItem } from '../../src/vscode-tests/factories/remote-queries/remote-query-history-item'; |
| 9 | + |
| 10 | +describe('Query history info', () => { |
| 11 | + describe('getRawQueryName', () => { |
| 12 | + it('should get the name for local history items', () => { |
| 13 | + const date = new Date('2022-01-01T00:00:00.000Z'); |
| 14 | + const dateStr = date.toLocaleString(); |
| 15 | + |
| 16 | + const queryHistoryItem = createMockLocalQueryInfo(dateStr); |
| 17 | + |
| 18 | + const queryName = getRawQueryName(queryHistoryItem); |
| 19 | + |
| 20 | + expect(queryName).to.equal(queryHistoryItem.getQueryName()); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should get the name for remote query history items', () => { |
| 24 | + const queryHistoryItem = createMockRemoteQueryHistoryItem({}); |
| 25 | + const queryName = getRawQueryName(queryHistoryItem); |
| 26 | + |
| 27 | + expect(queryName).to.equal(queryHistoryItem.remoteQuery.queryName); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should get the name for variant analysis history items', () => { |
| 31 | + const queryHistoryItem: VariantAnalysisHistoryItem = { |
| 32 | + t: 'variant-analysis', |
| 33 | + status: QueryStatus.InProgress, |
| 34 | + completed: false, |
| 35 | + variantAnalysis: createMockVariantAnalysis() |
| 36 | + }; |
| 37 | + |
| 38 | + const queryName = getRawQueryName(queryHistoryItem); |
| 39 | + |
| 40 | + expect(queryName).to.equal(queryHistoryItem.variantAnalysis.query.name); |
| 41 | + }); |
| 42 | + }); |
| 43 | +}); |
0 commit comments