johnny-cli
Version:
CLI for Johnny Deps
22 lines (18 loc) • 717 B
JavaScript
import JohnnyFile from 'JohnnyFile';
import mockFs from 'mock-fs';
describe('Johnny config file manager', () => {
it('doesn\'t rewrite existing config file, throwing error message', () => {
mockFs({'./johnny.json': 'config file content'});
expect(() => JohnnyFile().create({name: '', token: '', user: ''})).toThrow();
mockFs.restore();
});
it('can read single param from config file', () => {
const
config = {name: 'name', token: 'token', user: 'user'};
mockFs({'./johnny.json': JSON.stringify(config)});
expect(JohnnyFile().get('name')).toBe(config.name);
expect(JohnnyFile().get('token')).toBe(config.token);
expect(JohnnyFile().get('user')).toBe(config.user);
mockFs.restore();
});
});