mirror of
https://github.com/status-im/react-native.git
synced 2025-01-17 21:11:45 +00:00
1f498010e8
Summary: This is first PR from the series I am going to be sending as a result of fixing 0.50-stable test suite. This one removes `mockFS` dependency that has been causing failures on Node 6.x container. Here's build before this change: https://circleci.com/gh/facebook/react-native/22529 Here's build after this change: https://circleci.com/gh/facebook/react-native/22538 (green) Note that the CI may be still red as there are other PRs to be addressed. You can see this in the wild on 0.50. Closes https://github.com/facebook/react-native/pull/16301 Differential Revision: D6031352 Pulled By: hramos fbshipit-source-id: 5c97ae6c87864c094e29e5d8987521071c67f5bd
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @emails oncall+javascript_foundation
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
/* eslint-disable no-unclear-flowtypes */
|
|
|
|
declare var jest: any;
|
|
declare var describe: any;
|
|
declare var it: any;
|
|
|
|
jest.mock('fs');
|
|
|
|
const fs = require('fs');
|
|
|
|
describe('fs mock', () => {
|
|
describe('writeFileSync()', () => {
|
|
it('stores content correctly', () => {
|
|
fs.writeFileSync('/test', 'foobar', 'utf8');
|
|
const content = fs.readFileSync('/test', 'utf8');
|
|
/* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an
|
|
* error found when Flow v0.56 was deployed. To see the error delete this
|
|
* comment and run Flow. */
|
|
expect(content).toEqual('foobar');
|
|
});
|
|
|
|
it('fails on missing path', () => {
|
|
/* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an
|
|
* error found when Flow v0.56 was deployed. To see the error delete this
|
|
* comment and run Flow. */
|
|
expect(() =>
|
|
fs.writeFileSync('/dir/test', 'foobar', 'utf8'),
|
|
).toThrowError('ENOENT: no such file or directory');
|
|
});
|
|
});
|
|
|
|
describe('mkdirSync()', () => {
|
|
it('creates folders that we can write files in', () => {
|
|
fs.mkdirSync('/dir', 0o777);
|
|
fs.writeFileSync('/dir/test', 'foobar', 'utf8');
|
|
const content = fs.readFileSync('/dir/test', 'utf8');
|
|
/* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an
|
|
* error found when Flow v0.56 was deployed. To see the error delete this
|
|
* comment and run Flow. */
|
|
expect(content).toEqual('foobar');
|
|
});
|
|
});
|
|
});
|