/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js
53 строки
2 KB
Tim Yung
sort-imports: Update Rule Definition (#51880)
10 июн 2025, 06:30
10 июн 2025, 06:30
ad652cf
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format */ 'use strict'; const failureFixtures = require('../__test_fixtures__/failures.js'); const fixtures = require('../__test_fixtures__/fixtures.js'); const {FlowParser} = require('../../parser'); jest.mock('fs', () => ({ readFileSync: filename => { // Jest in the OSS does not allow to capture variables in closures. // Therefore, we have to bring the variables inside the closure. // see: https://github.com/facebook/jest/issues/2567 const readFileFixtures = require('../__test_fixtures__/fixtures.js'); const readFileFailureFixtures = require('../__test_fixtures__/failures.js'); return readFileFixtures[filename] || readFileFailureFixtures[filename]; }, })); const parser = new FlowParser(); describe('RN Codegen Flow Parser', () => { Object.keys(fixtures) .sort() .forEach(fixtureName => { it(`can generate fixture ${fixtureName}`, () => { const schema = parser.parseFile(fixtureName); const serializedSchema = JSON.stringify(schema, null, 2).replace( /"/g, "'", ); expect(serializedSchema).toMatchSnapshot(); }); }); Object.keys(failureFixtures) .sort() .forEach(fixtureName => { it(`Fails with error message ${fixtureName}`, () => { expect(() => { parser.parseFile(fixtureName); }).toThrowErrorMatchingSnapshot(); }); }); });