<commit_before>import {jsonArrayMember, jsonMapMember, jsonMember, jsonObject, TypedJSON} from '../src/typedjson';

describe('preserveNull', () => {
    it('should work globally', () => {
        TypedJSON.setGlobalConfig({preserveNull: true});

        @jsonObject
        class Person {
            @jsonMember
            name: string | null;
        }

        const input = new Person();
        input.name = null;
        const json = TypedJSON.toPlainJson(input, Person);
        expect(json).toEqual({name: null});

        const obj = TypedJSON.parse({name: null}, Person);
        expect(obj).toEqual(input);

        // @ts-ignore<commit_msg>Allow @ts-ignore on delete TypedJSON._globalConfig<commit_after>import {jsonArrayMember, jsonMapMember, jsonMember, jsonObject, TypedJSON} from '../src/typedjson';

describe('preserveNull', () => {
    it('should work globally', () => {
        TypedJSON.setGlobalConfig({preserveNull: true});

        @jsonObject
        class Person {
            @jsonMember
            name: string | null;
        }

        const input = new Person();
        input.name = null;
        const json = TypedJSON.toPlainJson(input, Person);
        expect(json).toEqual({name: null});

        const obj = TypedJSON.parse({name: null}, Person);
        expect(obj).toEqual(input);

        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
        // @ts-ignore
{'fraction_non_alphanumeric': 0.13517338995046002, 'fraction_numerical': 0.0, 'mean_word_length': 2.5261845386533666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5971853', 'n_tokens_mistral': 408, 'n_tokens_neox': 395, 'n_words': 85}