<commit_before>import {PropertiesModel} from "./propertiesModel";
import {RxVO} from "./rxvo";
import {default as deepEqual} from "deep-equal";
import {
    basicModel, nestedModel, nestedModelDefault, nestedPatternModel, patternModel
} from "../../fixtures/PropertiesModel.schemas";

describe("PropertiesModel Class Suite", function () {

    describe("Simple PropertiesModel Tests", () => {
        beforeEach(() => {
            this.rxvo = new RxVO({schemas: [basicModel]});
        });

        describe("LifeCycle: Instantiation", () => {
            it("should initialize a schema and a schema object", () => {
                expect(this.rxvo.model.$model).toBeDefined();
                expect(this.rxvo.model.$model instanceof PropertiesModel).toBe(true);
                expect(this.rxvo.model.$model).toBeDefined();
                expect(this.rxvo.model.$model instanceof PropertiesModel).toBe(true);
            });

            it("should not initialize a invalid schema and schema object", () => {
                let badSchema = Object.assign({}, basicModel, {
                    properties: {
                        "bad thing": {
                            type: "INVALID",
                        },
                    },
                });
                expect(() => new RxVO({schemas: [badSchema]})).toThrow();
            });
        });

        describe("LifeCycle: Creation", () => {

            let _d;

            it("should populate with valid data and make that data accessible", () => {
                _d = {
                    name: "<NAME>",
                    age: 99,
                    active: true,
                };

                this.rxvo.model = _d;
                expect(deepEqual(this.rxvo.model, _d)).toBe(true);
            });

            it("should reject invalid data and leave model pristine", () => {
                _d = {
                    name: "<NAME>",
                    age: 99,
                    active: "123",
                };

                this.rxvo.model = _d;
                expect(deepEqual(this.rxvo.model, {})).toBe(true);
            });
        });

        describe("LifeCycle: Update", () => {
            const _d = {
                name: "<NAME>",
                age: 99,
                active: true,
            };

            beforeEach(() => {
                this.rxvo.model = _d;
            });

            it("should update with valid data", () => {
                this.rxvo.model.active = false;
                expect(deepEqual(this.rxvo.model, _d)).toBe(false);
            });

            it("should reject invalid data update", () => {
                const _sub = this.rxvo.subscribe({
                    error: (e) => console.log(JSON.stringify(e)),
                });<commit_msg>rebuilt sources / removed console output<commit_after>import {PropertiesModel} from "./propertiesModel";
import {RxVO} from "./rxvo";
import {default as deepEqual} from "deep-equal";
import {
    basicModel, nestedModel, nestedModelDefault, nestedPatternModel, patternModel
} from "../../fixtures/PropertiesModel.schemas";

describe("PropertiesModel Class Suite", function () {

    describe("Simple PropertiesModel Tests", () => {
        beforeEach(() => {
            this.rxvo = new RxVO({schemas: [basicModel]});
        });

        describe("LifeCycle: Instantiation", () => {
            it("should initialize a schema and a schema object", () => {
                expect(this.rxvo.model.$model).toBeDefined();
                expect(this.rxvo.model.$model instanceof PropertiesModel).toBe(true);
                expect(this.rxvo.model.$model).toBeDefined();
                expect(this.rxvo.model.$model instanceof PropertiesModel).toBe(true);
            });

            it("should not initialize a invalid schema and schema object", () => {
                let badSchema = Object.assign({}, basicModel, {
                    properties: {
                        "bad thing": {
                            type: "INVALID",
                        },
                    },
                });
                expect(() => new RxVO({schemas: [badSchema]})).toThrow();
            });
        });

        describe("LifeCycle: Creation", () => {

            let _d;

            it("should populate with valid data and make that data accessible", () => {
                _d = {
                    name: "<NAME>",
                    age: 99,
                    active: true,
                };

                this.rxvo.model = _d;
                expect(deepEqual(this.rxvo.model, _d)).toBe(true);
            });

            it("should reject invalid data and leave model pristine", () => {
                _d = {
                    name: "<NAME>",
                    age: 99,
                    active: "123",
                };

                this.rxvo.model = _d;
                expect(deepEqual(this.rxvo.model, {})).toBe(true);
            });
        });

        describe("LifeCycle: Update", () => {
            const _d = {
                name: "<NAME>",
                age: 99,
                active: true,
            };

            beforeEach(() => {
                this.rxvo.model = _d;
            });

            it("should update with valid data", () => {
                this.rxvo.model.active = false;
                expect(deepEqual(this.rxvo.model, _d)).toBe(false);
            });

            it("should reject invalid data update", () => {
{'fraction_non_alphanumeric': 0.13773653566229985, 'fraction_numerical': 0.0032751091703056767, 'mean_word_length': 1.383781439722463, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 36, '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': '6326880', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1310, 'n_words': 300}