import {Valid} from "../../../source/constraints/valid.mjs";
import {Invalid} from "../../../source/constraints/invalid.mjs";
import {OrOperator} from "../../../source/constraints/oroperator.mjs";

describe('OrOperator', function () {

    describe('.isValid()', function () {

        [
            [new Valid(), new Valid(), true],
            [new Valid(), new Invalid(), true],
            [new Invalid(), new Valid(), true],
            [new Invalid(), new Invalid(), false]
        ].forEach(function (data) {

            let a = data.shift()
            let b = data.shift()
            let c = data.shift()

            it('constraint.isValid() should return ' + c, function (done) {

                let constraint = new OrOperator(a, b);
                constraint.isValid().then(() => {
                    c === true ? done() : done(new Error());
                }).catch(() => {
                    c === true ? done(new Error()) : done();
                })

            });

        });

    });
});

