Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/i18n / dist / src / onesky / utils.spec.js
Size: Mime:
const fs = require('fs');

const { writeJsonFile, readJsonFile, getResourceConfiguration } = require('./utils');

jest.mock('fs');

describe('Utility functions', () => {
  test('writeJsonFile', async () => {
    fs.writeFile.mockImplementation((_, __, cb) => {
      cb(null);
    });
    await writeJsonFile('i18n/en.json', { key: 'value' });
    expect(fs.writeFile).toHaveBeenCalledWith('i18n/en.json', '{"key":"value"}', expect.any(Function));
  });

  test('readJsonFile', async () => {
    fs.readFile.mockImplementation((_, cb) => {
      cb(null, '{"key":"value"}');
    });
    const config = await readJsonFile('i18n/en.json');
    expect(config).toEqual({ key: 'value' });
  });

  test('getResourceConfiguration', async () => {
    fs.readFile.mockImplementation((_, cb) => {
      cb(null, '{"key":"value"}');
    });
    const config = await getResourceConfiguration('.oneskyrc');
    expect(config).toEqual({ key: 'value' });
  });
});