<commit_before>const test = require('ava');

const BemEntityName = require('../index');

test('should create object for block', t => {
    const data = { block: 'b' };

    t.deepEqual((new BemEntityName(data)).valueOf(), data);
});

test('should create object for block and elem', t => {
    const data = { block: 'b', elem: 'e' };

    t.deepEqual((new BemEntityName(data)).valueOf(), data);
});

test('should create object for block and mod', t => {
    const data = { block: 'b', mod: { name: 'm', val: 'v' } };

    t.deepEqual((new BemEntityName(data)).valueOf(), data);
});

test('should create object and normalize boolean modifier', t => {
    const entity = new BemEntityName({ block: 'block', mod: { name: 'mod' } });

    t.deepEqual(entity.valueOf(), { block: 'block', mod: { name: 'mod', val: true } });
});

test('should throw error for if entity object is not valid', t => {
    t.throws(
        () => new BemEntityName({ elem: 'elem' }),
        /This is not valid BEM entity: the field `block` is undefined\./
    );
});

test('should throw error for if mod object is empty', t => {
    t.throws(
        () => new BemEntityName({ block: 'block', mod: {} }),
        /This is not valid BEM entity: the field `mod.name` is undefined\./
    );
});

test('should throw error for if mod name is undefined', t => {
    t.throws(
        () => new BemEntityName({ block: 'block', mod: { val: 'val' } }),
        /This is not valid BEM entity: the field `mod.name` is undefined\./
    );
});<commit_msg>test(error): error message more handy<commit_after>const test = require('ava');

const BemEntityName = require('../index');

test('should create object for block', t => {
    const data = { block: 'b' };

    t.deepEqual((new BemEntityName(data)).valueOf(), data);
});

test('should create object for block and elem', t => {
    const data = { block: 'b', elem: 'e' };

    t.deepEqual((new BemEntityName(data)).valueOf(), data);
});

test('should create object for block and mod', t => {
    const data = { block: 'b', mod: { name: 'm', val: 'v' } };

    t.deepEqual((new BemEntityName(data)).valueOf(), data);
});

test('should create object and normalize boolean modifier', t => {
    const entity = new BemEntityName({ block: 'block', mod: { name: 'mod' } });

    t.deepEqual(entity.valueOf(), { block: 'block', mod: { name: 'mod', val: true } });
});

test('should throw error for if entity object is not valid', t => {
    t.throws(
        () => new BemEntityName({ elem: 'elem' }),
        "The object `{ elem: 'elem' }` is not valid BEM entity: the field `block` is undefined"
    );
});

test('should throw error for if mod object is empty', t => {
    t.throws(
        () => new BemEntityName({ block: 'block', mod: {} }),
        "The object `{ block: 'block', mod: {} }` is not valid BEM entity: the field `mod.name` is undefined"
    );
});

test('should throw error for if mod name is undefined', t => {
    t.throws(
        () => new BemEntityName({ block: 'block', mod: { val: 'val' } }),
        "The object `{ block: 'block', mod: { val: 'val' } }` is not valid BEM entity: the field `mod.name` is undefined"
    );
});
{'fraction_non_alphanumeric': 0.18656952803294266, 'fraction_numerical': 0.0, 'mean_word_length': 3.250336473755047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1321875', 'n_tokens_mistral': 1001, 'n_tokens_neox': 994, 'n_words': 345}