|
| 1 | +import FailedTestsCache from '../failed_tests_cache'; |
| 2 | + |
| 3 | +describe('FailedTestsCache', () => { |
| 4 | + test('should filter tests', () => { |
| 5 | + const failedTestsCache = new FailedTestsCache(); |
| 6 | + failedTestsCache.setTestResults([ |
| 7 | + { |
| 8 | + numFailingTests: 0, |
| 9 | + testFilePath: '/path/to/passing.js', |
| 10 | + testResults: [ |
| 11 | + {fullName: 'test 1', status: 'passed'}, |
| 12 | + {fullName: 'test 2', status: 'passed'}, |
| 13 | + ], |
| 14 | + }, |
| 15 | + { |
| 16 | + numFailingTests: 2, |
| 17 | + testFilePath: '/path/to/failed_1.js', |
| 18 | + testResults: [ |
| 19 | + {fullName: 'test 3', status: 'failed'}, |
| 20 | + {fullName: 'test 4', status: 'failed'}, |
| 21 | + ], |
| 22 | + }, |
| 23 | + { |
| 24 | + numFailingTests: 1, |
| 25 | + testFilePath: '/path/to/failed_2.js', |
| 26 | + testResults: [ |
| 27 | + {fullName: 'test 5', status: 'failed'}, |
| 28 | + {fullName: 'test 6', status: 'passed'}, |
| 29 | + ], |
| 30 | + }, |
| 31 | + ]); |
| 32 | + |
| 33 | + const result = failedTestsCache.filterTests([ |
| 34 | + { |
| 35 | + path: '/path/to/passing.js', |
| 36 | + }, |
| 37 | + { |
| 38 | + path: '/path/to/failed_1.js', |
| 39 | + }, |
| 40 | + { |
| 41 | + path: '/path/to/failed_2.js', |
| 42 | + }, |
| 43 | + { |
| 44 | + path: '/path/to/unknown.js', |
| 45 | + }, |
| 46 | + ]); |
| 47 | + expect(result).toMatchObject([ |
| 48 | + { |
| 49 | + path: '/path/to/failed_1.js', |
| 50 | + }, |
| 51 | + { |
| 52 | + path: '/path/to/failed_2.js', |
| 53 | + }, |
| 54 | + ]); |
| 55 | + expect(failedTestsCache.updateConfig({})).toMatchObject({ |
| 56 | + enabledTestsMap: { |
| 57 | + '/path/to/failed_1.js': {'test 3': true, 'test 4': true}, |
| 58 | + '/path/to/failed_2.js': {'test 5': true}, |
| 59 | + }, |
| 60 | + }); |
| 61 | + }); |
| 62 | +}); |
0 commit comments