Skip to content

Commit b2f4fec

Browse files
committed
Move createMockLocalQueryInfo into shared location
1 parent 21b6adb commit b2f4fec

File tree

2 files changed

+37
-28
lines changed

2 files changed

+37
-28
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {
2+
InitialQueryInfo,
3+
CompletedQueryInfo,
4+
CompletedLocalQueryInfo,
5+
LocalQueryInfo,
6+
} from '../../../query-results';
7+
8+
export function createMockLocalQueryInfo(
9+
startTime: string,
10+
userSpecifiedLabel?: string
11+
): LocalQueryInfo {
12+
return ({
13+
t: 'local',
14+
userSpecifiedLabel,
15+
startTime: startTime,
16+
getQueryFileName() {
17+
return 'query-file.ql';
18+
},
19+
getQueryName() {
20+
return 'query-name';
21+
},
22+
initialInfo: ({
23+
databaseInfo: {
24+
databaseUri: 'unused',
25+
name: 'db-name',
26+
},
27+
} as unknown) as InitialQueryInfo,
28+
completedQuery: ({
29+
resultCount: 456,
30+
statusString: 'in progress',
31+
} as unknown) as CompletedQueryInfo,
32+
} as unknown) as CompletedLocalQueryInfo;
33+
}

extensions/ql-vscode/src/vscode-tests/no-workspace/history-item-label-provider.test.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { env } from 'vscode';
22
import { expect } from 'chai';
33
import { QueryHistoryConfig } from '../../config';
44
import { HistoryItemLabelProvider } from '../../history-item-label-provider';
5-
import { CompletedLocalQueryInfo, CompletedQueryInfo, InitialQueryInfo } from '../../query-results';
65
import { QueryHistoryInfo } from '../../query-history-info';
76
import { RemoteQueryHistoryItem } from '../../remote-queries/remote-query-history-item';
7+
import { createMockLocalQueryInfo } from '../factories/local-queries/local-query-history-item';
88

99

1010
describe('HistoryItemLabelProvider', () => {
@@ -23,7 +23,7 @@ describe('HistoryItemLabelProvider', () => {
2323

2424
describe('local queries', () => {
2525
it('should interpolate query when user specified', () => {
26-
const fqi = createMockLocalQueryInfo('xxx');
26+
const fqi = createMockLocalQueryInfo(dateStr, 'xxx');
2727

2828
expect(labelProvider.getLabel(fqi)).to.eq('xxx');
2929

@@ -35,7 +35,7 @@ describe('HistoryItemLabelProvider', () => {
3535
});
3636

3737
it('should interpolate query when not user specified', () => {
38-
const fqi = createMockLocalQueryInfo();
38+
const fqi = createMockLocalQueryInfo(dateStr);
3939

4040
expect(labelProvider.getLabel(fqi)).to.eq('xxx query-name xxx');
4141

@@ -48,7 +48,7 @@ describe('HistoryItemLabelProvider', () => {
4848
});
4949

5050
it('should get query short label', () => {
51-
const fqi = createMockLocalQueryInfo('xxx');
51+
const fqi = createMockLocalQueryInfo(dateStr, 'xxx');
5252

5353
// fall back on user specified if one exists.
5454
expect(labelProvider.getShortLabel(fqi)).to.eq('xxx');
@@ -57,30 +57,6 @@ describe('HistoryItemLabelProvider', () => {
5757
delete (fqi as any).userSpecifiedLabel;
5858
expect(labelProvider.getShortLabel(fqi)).to.eq('query-name');
5959
});
60-
61-
function createMockLocalQueryInfo(userSpecifiedLabel?: string) {
62-
return {
63-
t: 'local',
64-
userSpecifiedLabel,
65-
startTime: date.toLocaleString(env.language),
66-
getQueryFileName() {
67-
return 'query-file.ql';
68-
},
69-
getQueryName() {
70-
return 'query-name';
71-
},
72-
initialInfo: {
73-
databaseInfo: {
74-
databaseUri: 'unused',
75-
name: 'db-name'
76-
}
77-
} as unknown as InitialQueryInfo,
78-
completedQuery: {
79-
resultCount: 456,
80-
statusString: 'in progress',
81-
} as unknown as CompletedQueryInfo,
82-
} as unknown as CompletedLocalQueryInfo;
83-
}
8460
});
8561

8662
describe('remote queries', () => {

0 commit comments

Comments
 (0)