<commit_before>h = require('./helper.coffee')

MultiValidator = h.requireValidator('multi')

describe "MultiValidator", ->
  lazy "validator", -> new MultiValidator()

  describe "#add", ->
    it "throws an error when you try to add an async validator", (validator, asyncValidator) ->
      expect(-> validator.add(asyncValidator)).throw("Can't add async validators into the MultiValidator, use the MultiAsyncValidator instead.")

  describe "#test", ->
    describe "empty validator", ->
      it "passes the test", (validator) ->
        h.testPass(validator, {})

    describe "given there is a failed validation", ->
      it "fails the test", (validator, failValidator) ->
        validator.add(failValidator)

        h.testFail(validator, {})

    describe "given there is a passing validation", ->
      it "passes the test", (validator, passValidator) ->
        validator.add(passValidator)

        h.testPass(validator, 'value')
        expect(passValidator.test.calledWith('value')).true<commit_msg>add test to cover adding async validators into possible async multi validator<commit_after>h = require('./helper.coffee')

MultiValidator = h.requireValidator('multi')

describe "MultiValidator", ->
  lazy "validator", -> new MultiValidator()

  describe "#add", ->
    it "throws an error when you try to add an async validator", (validator, asyncValidator) ->
      expect(-> validator.add(asyncValidator)).throw("Can't add async validators into the MultiValidator, use the MultiAsyncValidator instead.")

    it "doesn't throw an error when you add an async validator to an async MultiValidator", (validator, asyncValidator) ->
      validator.async = -> true

      expect(-> validator.add(asyncValidator)).not.throw()

  describe "#test", ->
    describe "empty validator", ->
      it "passes the test", (validator) ->
        h.testPass(validator, {})

    describe "given there is a failed validation", ->
      it "fails the test", (validator, failValidator) ->
        validator.add(failValidator)

        h.testFail(validator, {})

    describe "given there is a passing validation", ->
      it "passes the test", (validator, passValidator) ->
        validator.add(passValidator)

        h.testPass(validator, 'value')
        expect(passValidator.test.calledWith('value')).true
{'fraction_non_alphanumeric': 0.12749349522983522, 'fraction_numerical': 0.0, 'mean_word_length': 3.5324165029469548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '2548176', 'n_tokens_mistral': 623, 'n_tokens_neox': 621, 'n_words': 193}