'use strict';

const path = require('path');
const pluginWarnAboutFoo = require('./fixtures/plugin-warn-about-foo');
const printConfig = require('../printConfig');

it('printConfig uses getConfigForFile to retrieve the config', () => {
	const filepath = path.join(__dirname, 'fixtures/getConfigForFile/a/b/foo.css');

	return printConfig({
		files: [filepath],
	}).then((result) => {
		expect(result).toEqual({
			plugins: [path.join(__dirname, '/fixtures/plugin-warn-about-foo.js')],
			rules: {
				'block-no-empty': [true],
				'plugin/warn-about-foo': ['always'],
			},
			pluginFunctions: {
				'plugin/warn-about-foo': pluginWarnAboutFoo.rule,
			},
		});
	});
});

it('printConfig with input css should throw', () => {
	return expect(
		printConfig({
			code: 'a {}',
		}),
	).rejects.toThrow('The --print-config option must be used with exactly one file path.');
});

it('printConfig with no path should throw', () => {
	return expect(
		printConfig({
			files: [],
		}),
	).rejects.toThrow('The --print-config option must be used with exactly one file path.');
});

it('printConfig with multiple paths should throw', () => {
	return expect(
		printConfig({
			files: ['./first-path.css', './second-path.css'],
		}),
	).rejects.toThrow('The --print-config option must be used with exactly one file path.');
});

it('printConfig with globs should throw', () => {
	return expect(
		printConfig({
			files: ['./*.css'],
		}),
	).rejects.toThrow('The --print-config option does not support globs.');
});

@@ -156,16 +156,76 @@
 onfig');
+%0Aconst replaceBackslashes = require('./replaceBackslashes');
 %0A%0Ait('pr
@@ -307,16 +307,38 @@
 epath = 
+replaceBackslashes(%0A%09%09
 path.joi
@@ -389,16 +389,20 @@
 foo.css'
+),%0A%09
 );%0A%0A%09ret
@@ -503,16 +503,35 @@
 ugins: %5B
+replaceBackslashes(
 path.joi
@@ -580,16 +580,17 @@
 foo.js')
+)
 %5D,%0A%09%09%09ru

Fix Windows path problem