test(ivy): ensure that `runInEachFileSystem` cleans up after itself (#31544)

Previously the last file-system being tested was left as the current
file-system. Now it is reset to an `InvalidFileSystem` to ensure future
tests are not affected.

PR Close #31544
This commit is contained in:
Pete Bacon Darwin 2019-07-18 21:05:31 +01:00 committed by Misko Hevery
parent f69e4e6f77
commit 97ab52c618
1 changed files with 2 additions and 0 deletions

View File

@ -9,6 +9,7 @@
import * as ts from 'typescript'; import * as ts from 'typescript';
import {absoluteFrom, setFileSystem} from '../../src/helpers'; import {absoluteFrom, setFileSystem} from '../../src/helpers';
import {InvalidFileSystem} from '../../src/invalid_file_system';
import {AbsoluteFsPath} from '../../src/types'; import {AbsoluteFsPath} from '../../src/types';
import {MockFileSystem} from './mock_file_system'; import {MockFileSystem} from './mock_file_system';
@ -43,6 +44,7 @@ function runInEachFileSystemFn(callback: (os: string) => void) {
function runInFileSystem(os: string, callback: (os: string) => void, error: boolean) { function runInFileSystem(os: string, callback: (os: string) => void, error: boolean) {
describe(`<<FileSystem: ${os}>>`, () => { describe(`<<FileSystem: ${os}>>`, () => {
beforeEach(() => initMockFileSystem(os)); beforeEach(() => initMockFileSystem(os));
afterEach(() => setFileSystem(new InvalidFileSystem()));
callback(os); callback(os);
if (error) { if (error) {
afterAll(() => { throw new Error(`runInFileSystem limited to ${os}, cannot pass`); }); afterAll(() => { throw new Error(`runInFileSystem limited to ${os}, cannot pass`); });