/
formatTestResults.test.ts
86 lines (76 loc) · 2.39 KB
/
formatTestResults.test.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import formatTestResults from '../formatTestResults';
import type {AggregatedResult, AssertionResult} from '../types';
describe('formatTestResults', () => {
it('includes test full name', () => {
const assertion = {
fullName: 'TestedModule#aMethod when some condition is met returns true',
status: 'passed',
title: 'returns true',
} as AssertionResult;
const results = {
testResults: [
{
numFailingTests: 0,
perfStats: {end: 2, runtime: 1, slow: false, start: 1},
testResults: [assertion],
},
],
} as AggregatedResult;
const result = formatTestResults(results, undefined, null);
expect(result.testResults[0].assertionResults[0].fullName).toEqual(
assertion.fullName,
);
});
it('should mark result status to skipped', () => {
const skippedAssertion = {
fullName: 'Pending test',
status: 'pending',
title: 'is still pending',
} as AssertionResult;
const skippedResults = {
testResults: [
{
numFailingTests: 0,
numPassingTests: 0,
numPendingTests: 2,
numTodoTests: 2,
perfStats: {end: 2, runtime: 1, slow: false, start: 1},
testResults: [skippedAssertion],
},
],
} as AggregatedResult;
const result = formatTestResults(skippedResults, undefined, null);
expect(result.testResults[0].assertionResults[0].status).toEqual(
skippedAssertion.status,
);
});
it('should mark result status to focused', () => {
const focusedAssertion = {
fullName: 'Focused test',
status: 'focused',
title: 'focused test',
} as AssertionResult;
const focusedResults = {
testResults: [
{
numFailingTests: 0,
numPassingTests: 1,
numPendingTests: 1,
numTodoTests: 2,
perfStats: {end: 2, runtime: 1, slow: false, start: 1},
testResults: [focusedAssertion],
},
],
} as AggregatedResult;
const result = formatTestResults(focusedResults, undefined, null);
expect(result.testResults[0].assertionResults[0].status).toEqual(
focusedAssertion.status,
);
});
});