-
Notifications
You must be signed in to change notification settings - Fork 67
/
TestOutput.model.ts
43 lines (39 loc) 路 1008 Bytes
/
TestOutput.model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {TTestSchemas} from 'types/Common.types';
export type TRawTestOutput = TTestSchemas['TestOutput'];
type TestOutput = {
isDeleted: boolean;
isDraft: boolean;
name: string;
selector: string;
value: string;
valueRun: string;
valueRunDraft: string;
id: number;
spanId: string;
error: string;
};
function TestOutput({name = '', selectorParsed = {}, selector = '', value = ''}: TRawTestOutput, id = -1): TestOutput {
return {
id,
isDeleted: false,
isDraft: false,
name,
selector: selectorParsed.query || selector || '',
value,
valueRun: '',
valueRunDraft: '',
spanId: '',
error: '',
};
}
export function toRawTestOutputs(testOutputs: TestOutput[]): TRawTestOutput[] {
return testOutputs
.filter(output => !output.isDeleted)
.map<TRawTestOutput>(output => ({
name: output.name,
selector: output.selector,
selectorParsed: {query: output.selector},
value: output.value,
}));
}
export default TestOutput;