<commit_before>import * as chai from 'chai';
import {expect} from 'chai';
import Jsona from '../src';

import {
    town1,
    town2,
    user1,
    user2,
    specialty1,
    specialty2,
    country1,
    country2,
    reduxObject1,
    circular,
    duplicate,
    reduxObjectWithCircular,
    withoutRootIdsMock,
    withNullRelationsMock,
    resourceIdObjMetaMock,
} from './mocks';

chai.config.showDiff = true;
chai.config.truncateThreshold = 0;

describe('Jsona', () => {
    const jsona = new Jsona();

    it('should instantiate with fallback property mappers', () => {
        let jsona = new Jsona();
    });

    describe('serialize', () => {
        it('should throw Error if stuff is not passed', () => {
            expect(jsona.serialize.bind(jsona, {stuff: null})).to.throw(Error);
        });

        it('should build json with item, without included', () => {
            const jsonBody = jsona.serialize({stuff: town1.model});
            expect(jsonBody.data).to.be.deep.equal(town1.json);
            expect(jsonBody.included).to.be.equal(undefined);
        });

        it('should build json with collection, with included', () => {
            const jsonBody = jsona.serialize({stuff: user2.model, includeNames: ['specialty', 'town.country']});
            expect(jsonBody.data).to.be.deep.equal(user2.json);
            expect(jsonBody.included).to.be.deep.equal([specialty1.json, specialty2.json, town2.json, country2.json]);
        });

        it('should build json and save null relationships', () => {
            const jsonBody = jsona.serialize({stuff: withNullRelationsMock.collection});
            expect(jsonBody.data).to.be.deep.equal(withNullRelationsMock.json);
        });
    });

    describe('deserialize', () => {
        it('should throw Error if body is not passed', () => {
            expect(jsona.serialize.bind(jsona, null)).to.throw(Error);
            expect(jsona.serialize.bind(jsona, undefined)).to.throw(Error);<commit_msg>Update deserialize specs to call correct function<commit_after>import * as chai from 'chai';
import {expect} from 'chai';
import Jsona from '../src';

import {
    town1,
    town2,
    user1,
    user2,
    specialty1,
    specialty2,
    country1,
    country2,
    reduxObject1,
    circular,
    duplicate,
    reduxObjectWithCircular,
    withoutRootIdsMock,
    withNullRelationsMock,
    resourceIdObjMetaMock,
} from './mocks';

chai.config.showDiff = true;
chai.config.truncateThreshold = 0;

describe('Jsona', () => {
    const jsona = new Jsona();

    it('should instantiate with fallback property mappers', () => {
        let jsona = new Jsona();
    });

    describe('serialize', () => {
        it('should throw Error if stuff is not passed', () => {
            expect(jsona.serialize.bind(jsona, null)).to.throw(Error);
            expect(jsona.serialize.bind(jsona, undefined)).to.throw(Error);
            expect(jsona.serialize.bind(jsona, {stuff: null})).to.throw(Error);
        });

        it('should build json with item, without included', () => {
            const jsonBody = jsona.serialize({stuff: town1.model});
            expect(jsonBody.data).to.be.deep.equal(town1.json);
            expect(jsonBody.included).to.be.equal(undefined);
        });

        it('should build json with collection, with included', () => {
            const jsonBody = jsona.serialize({stuff: user2.model, includeNames: ['specialty', 'town.country']});
            expect(jsonBody.data).to.be.deep.equal(user2.json);
            expect(jsonBody.included).to.be.deep.equal([specialty1.json, specialty2.json, town2.json, country2.json]);
        });

        it('should build json and save null relationships', () => {
            const jsonBody = jsona.serialize({stuff: withNullRelationsMock.collection});
            expect(jsonBody.data).to.be.deep.equal(withNullRelationsMock.json);
        });
    });

    describe('deserialize', () => {
        it('should throw Error if body is not passed', () => {
            expect(jsona.deserialize.bind(jsona, null)).to.throw(Error);
            expect(jsona.deserialize.bind(jsona, undefined)).to.throw(Error);
{'fraction_non_alphanumeric': 0.14736335179388393, 'fraction_numerical': 0.008668432458463762, 'mean_word_length': 2.800548947849954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1314564', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1227, 'n_words': 247}