UNPKG

sharec-core

Version:

[![.github/workflows/main.yml](https://github.com/lamartire/sharec/workflows/.github/workflows/main.yml/badge.svg)](https://github.com/lamartire/sharec/actions) [![npm](https://img.shields.io/npm/v/sharec)](https://npmjs.com/sharec) ![MIT License](https:/

66 lines (59 loc) 2.26 kB
const { fixtures } = require('testUtils') const { vol } = require('memfs') const mergeConfigsPackages = require('../../mergeConfigsPackages') describe('steps > mergeConfigsPackages > mixed', () => { const semaphore = { start: jest.fn(), success: jest.fn(), error: jest.fn(), fail: jest.fn(), } let context const packageBaseFxt = fixtures('package/json/00-base') const eslintBaseFxt = fixtures('eslint/json/01-base') const babelBaseFxt = fixtures('babel/json/00-base') const npmignoreBaseFxt = fixtures('npmignore/lines/00-base') const gitignoreBaseFxt = fixtures('gitignore/lines/00-base') const yaspellerBaseFxt = fixtures('yaspeller/json/00-base') beforeEach(() => { jest.clearAllMocks() vol.reset() }) it('merge and writes configs and package.json', async () => { context = { targetPath: '/target', options: {}, mergedConfigs: {}, configs: [ { name: 'awesome-config', version: '1.0.0', configs: { 'package.json': packageBaseFxt.upcoming, '.eslintrc': eslintBaseFxt.upcoming, '.babelrc': babelBaseFxt.upcoming, '.npmignore': npmignoreBaseFxt.upcoming, '.gitignore': gitignoreBaseFxt.upcoming, '.yaspellerrc': yaspellerBaseFxt.upcoming, }, }, ], } const dir = { '/target/package.json': packageBaseFxt.current, '/target/.eslintrc': eslintBaseFxt.current, '/target/.babelrc': babelBaseFxt.current, '/target/.npmignore': npmignoreBaseFxt.current, '/target/.gitignore': gitignoreBaseFxt.current, '/target/.yaspellerrc': yaspellerBaseFxt.current, } vol.fromJSON(dir, '/configs') const output = await mergeConfigsPackages(context, semaphore) expect(output.mergedConfigs['/target/.eslintrc']).toMatchSnapshot() expect(output.mergedConfigs['/target/.babelrc']).toMatchSnapshot() expect(output.mergedConfigs['/target/.npmignore']).toMatchSnapshot() expect(output.mergedConfigs['/target/.gitignore']).toMatchSnapshot() expect(output.mergedConfigs['/target/.yaspellerrc']).toMatchSnapshot() expect(output.mergedConfigs['/target/package.json']).toMatchSnapshot() }) })