<commit_before>import test from 'ava';
import resolveExtends from './resolve-extends';

const _ = undefined;

test('returns empty object when called without params', t => {
	const actual = resolveExtends();
	t.deepEqual(actual, {});
});

test('returns an equivalent object as passed in', t => {
	const expected = {foo: 'bar'};
	const actual = resolveExtends(expected);
	t.deepEqual(actual, expected);
});

test('uses empty prefix by default', t => {
	const input = {extends: ['extender-name']};

	resolveExtends(input, _, _, id => {
		t.is(id, 'extender-name');
	});
});

test('uses prefix as configured', t => {
	const input = {extends: ['extender-name']};

	resolveExtends(input, 'prefix', _, id => {
		t.is(id, 'prefix-extender-name');
	});
});

test('ignores prefix for scoped extends', t => {
	const input = {extends: ['@scope/extender-name']};

	resolveExtends(input, 'prefix', _, id => {
		t.is(id, '@scope/extender-name');
	});
});

test('uses extends key as configured', t => {
	const input = {inherit: ['extender-name'], extends: ['fails']};

	resolveExtends(input, _, 'inherit', id => {
		t.is(id, 'extender-name');
	});
});

test('propagates return value of require function', t => {
	const input = {extends: ['extender-name']};
	const propagated = {foo: 'bar'};

	const actual = resolveExtends(input, _, _, () => {
		return propagated;
	});

	t.is(actual.foo, 'bar');
});

test('resolves extends recursively', t => {<commit_msg>test(core): add test case for relative extend items<commit_after>import test from 'ava';
import resolveExtends from './resolve-extends';

const _ = undefined;

test('returns empty object when called without params', t => {
	const actual = resolveExtends();
	t.deepEqual(actual, {});
});

test('returns an equivalent object as passed in', t => {
	const expected = {foo: 'bar'};
	const actual = resolveExtends(expected);
	t.deepEqual(actual, expected);
});

test('uses empty prefix by default', t => {
	const input = {extends: ['extender-name']};

	resolveExtends(input, _, _, id => {
		t.is(id, 'extender-name');
	});
});

test('uses prefix as configured', t => {
	const input = {extends: ['extender-name']};

	resolveExtends(input, 'prefix', _, id => {
		t.is(id, 'prefix-extender-name');
	});
});

test('ignores prefix for scoped extends', t => {
	const input = {extends: ['@scope/extender-name']};

	resolveExtends(input, 'prefix', _, id => {
		t.is(id, '@scope/extender-name');
	});
});

test.failing('ignores prefix for relative extends', t => {
	const input = {extends: ['./extender']};

	resolveExtends(input, 'prefix', _, id => {
		t.is(id, './extender');
	});
});

test('uses extends key as configured', t => {
	const input = {inherit: ['extender-name'], extends: ['fails']};

	resolveExtends(input, _, 'inherit', id => {
		t.is(id, 'extender-name');
	});
});

test('propagates return value of require function', t => {
	const input = {extends: ['extender-name']};
	const propagated = {foo: 'bar'};

	const actual = resolveExtends(input, _, _, () => {
		return propagated;
	});

	t.is(actual.foo, 'bar');
});

test('resolves extends recursively', t => {
{'fraction_non_alphanumeric': 0.19922630560928434, 'fraction_numerical': 0.0, 'mean_word_length': 4.641818181818182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1785422', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1033, 'n_words': 272}