Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
' # Should not be removed below\n';
fs.existsSync = jest.fn().mockImplementation(() => true);
const originalFileReadSync = fs.readFileSync;
fs.readFileSync = jest.fn().mockImplementation(() => configFileContent);
const config = new Config(path.resolve(outPath, 'ant.yml'));
const configPath = config.addPlugin('/foo/bar/myplugin').save();
const actualConfigFileContent = originalFileReadSync(configPath, 'utf-8');
// Notice that the empty line is removed when the yaml tree is rendered
expect(actualConfigFileContent).toBe('# Should not be removed\n' +
'plugins:\n' +
' - ./plugins/core\n' +
' - /foo/bar/myplugin\n' +
' # Should not be removed below\n');
expect(yaml.parse(actualConfigFileContent)).toEqual(
{ plugins: [ './plugins/core', '/foo/bar/myplugin' ] }
);
}
);
test('Should be rendered by createService', async () => {
const outPath = await (new Core(new Ant())).createService(
'MyService',
'Default'
);
expect(fs.readdirSync(outPath)).toEqual(['ant.yml', 'model.graphql']);
expect(
yaml.parse(
fs.readFileSync(path.resolve(outPath, 'ant.yml'), 'utf8')
).service
).toEqual('MyService');
makeExecutableSchema({
typeDefs: fs.readFileSync(
path.resolve(outPath, 'model.graphql'),
'utf8'
)
});
const originalCwd = process.cwd();
process.chdir(path.resolve(
utilPath,
'configs/graphQLPluginConfig'
));
const originalLog = console.log;
console.log = jest.fn();
const {
_: args,
config: configFile = 'slater.config.js',
env = 'development',
debug,
...props
} = require('minimist')(process.argv.slice(2))
if (debug) require('inspector').open()
const watch = args[0] === 'watch'
const deploy = args[0] === 'deploy'
const build = args[0] === 'build' || (!watch && !deploy)
const gitignore = fs.readFileSync(join('.gitignore'))
const userConfig = fs.existsSync(join(configFile)) ? require(join(configFile)) : {}
const themeConfig = yaml.parse(fs.readFileSync(join('src/config.yml'), 'utf8'))[env]
let ignoredFiles = [
'**/scripts/**',
'**/styles/**',
/DS_Store/
].concat(
themeConfig.ignore_files || []
).concat(
gitignore ? require('parse-gitignore')(gitignore) : []
)
const theme = themekit({
password: themeConfig.password,
store: themeConfig.store,
theme_id: themeConfig.theme_id,
ignore_files: ignoredFiles
async () => {
const configFilePath = path.resolve(outPath, 'ant.yml');
fsExtra.ensureFileSync(configFilePath);
let config = new Config(configFilePath);
const localConfigFilePath = config.addPlugin('/reading/from/file').save();
config = new Config(localConfigFilePath);
const configPath = config.removePlugin('/reading/from/file').save();
expect(configPath).toBe(localConfigFilePath);
expect(yaml.parse(fs.readFileSync(configPath, 'utf-8'))).toEqual({ plugins: [] });
}
);