<commit_before>import test from 'ava';
import { HasChildQuery, hasChildQuery, TermQuery } from '../../src';
import { nameExpectStrategy, makeSetsOptionMacro } from '../_macros';

const setsOption = makeSetsOptionMacro(hasChildQuery, nameExpectStrategy('has_child'));

const qry = new TermQuery('user', 'kimchy');

test(setsOption, 'type', { param: 'blog_tag', keyName: 'child_type' });
test(setsOption, 'childType', { param: 'blog_tag' });
test(setsOption, 'minChildren', { param: 2 });
test(setsOption, 'maxChildren', { param: 10 });

test('constructor sets argumetns', t => {
    const valueA = new HasChildQuery(qry, 'my_type').toJSON();
    const valueB = new HasChildQuery().childType('my_type').query(qry).toJSON();
    t.deepEqual(valueA, valueB);

    const expected = {
        has_child: {
            query: { term: { user: 'kimchy' } },
            child_type: 'my_type'
        }
    };
    t.deepEqual(valueA, expected);
});<commit_msg>test: Change HasChildQuery tests to use type instead of child_type<commit_after>import test from 'ava';
import { HasChildQuery, hasChildQuery, TermQuery } from '../../src';
import { nameExpectStrategy, makeSetsOptionMacro } from '../_macros';

const setsOption = makeSetsOptionMacro(hasChildQuery, nameExpectStrategy('has_child'));

const qry = new TermQuery('user', 'kimchy');

test(setsOption, 'type', { param: 'blog_tag' });
test(setsOption, 'childType', { param: 'blog_tag', keyName: 'type' });
test(setsOption, 'minChildren', { param: 2 });
test(setsOption, 'maxChildren', { param: 10 });

test('constructor sets argumetns', t => {
    const valueA = new HasChildQuery(qry, 'my_type').toJSON();
    const valueB = new HasChildQuery().childType('my_type').query(qry).toJSON();
    t.deepEqual(valueA, valueB);

    const expected = {
        has_child: {
            query: { term: { user: 'kimchy' } },
            type: 'my_type'
        }
    };
    t.deepEqual(valueA, expected);
});
{'fraction_non_alphanumeric': 0.16434827408552294, 'fraction_numerical': 0.0030911901081916537, 'mean_word_length': 4.2771739130434785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4030366', 'n_tokens_mistral': 627, 'n_tokens_neox': 616, 'n_words': 145}