it('functions as expected', function () {
          expect(
            value,
            'provides consumer correct value via onChange() property'
          )
            .to.eql({
              foo: input
            })

          expect(
            validationResult,
            'provides consumer with validation results via onValidation() property'
          )
            .not.to.equal(undefined)

          expect(
            validationResult.errors,
            'has no validation errors'
          )
            .to.eql([])

          expect(
            validationResult.warnings,
            'has no validation warnings'
          )
            .to.eql([])

          expectTextInputWithState('bunsenForm-foo-input', {
            placeholder: '',
            value: input
          })
        })
    it('renders as expected', function () {
      expectCollapsibleHandles(1)

      const $headings = this.$(selectors.bunsen.section.heading)

      expect(
        $headings,
        'renders correct number of headings'
      )
        .to.have.length(1)

      expect(
        $headings.first().text().trim(),
        'renders correct heading text for first input'
      )
        .to.equal('Bar')

      expect(
        this.$(selectors.bunsen.renderer.text),
        'renders two bunsen text inputs'
      )
        .to.have.length(2)

      expect(
        findTextInputs(),
        'renders two text input'
      )
        .to.have.length(2)

      expectTextInputWithState('bunsenForm-foo-input', {
        placeholder: '',
        value: ''
      })
    })
        it('renders as expected', function () {
          const $headings = this.$(selectors.bunsen.section.heading)

          expect(
            $headings,
            'renders a cell heading'
          )
            .to.have.length(1)

          const headingText = $headings
            .clone().children().remove().end() // Remove required DOM to get just the heading
            .text().trim()

          expect(
            headingText,
            'renders expected heading text'
          )
            .to.equal('Foo')

          expect(
            this.$(selectors.bunsen.section.required),
            'does not render required text in heading'
          )
            .to.have.length(0)

          expect(
            this.$(selectors.bunsen.renderer.text),
            'renders a bunsen text input'
          )
            .to.have.length(1)

          expect(
            findTextInputs(),
            'renders one text input'
          )
            .to.have.length(1)

          expectTextInputWithState('bunsenForm-foo.bar-input', {
            placeholder: ''
          })

          const label = this.$(selectors.bunsen.label)
            .clone().children().remove().end() // Remove required DOM to get just the heading
            .text().trim()

          expect(
            label,
            'renders expected label text'
          )
            .to.equal('Bar')

          expect(
            this.$(selectors.error),
            'does not have any validation errors'
          )
            .to.have.length(0)

          expectOnValidationState(ctx, {count: 1})
        })
          it('renders as expected', function () {
            expectTextInputWithState('bunsenForm-foo-input', {
              placeholder: '',
              value: input
            })

            expectBunsenInputNotToHaveError('foo')
          })
    it('renders as expected', function () {
      expect(
        this.$(selectors.bunsen.renderer.text),
        'renders two bunsen text inputs'
      )
        .to.have.length(2)

      expect(
        findTextInputs(),
        'renders two text inputs'
      )
        .to.have.length(2)

      expectTextInputWithState('bunsenForm-foo.0.settings.boo-input', {
        placeholder: '',
        value: 'test1'
      })

      expectTextInputWithState('bunsenForm-foo.0.settings.moo-input', {
        placeholder: '',
        value: 'test2'
      })

      const $labels = this.$(selectors.bunsen.label)

      expect(
        $labels,
        'renders two labels'
      )
        .to.have.length(2)

      expect(
        $labels.first().text().trim(),
        'renders expected label text'
      )
        .to.equal('Boo')

      expect(
        $labels.last().text().trim(),
        'renders expected label text'
      )
        .to.equal('Moo')
    })
Beispiel #6
0
    it('renders as expected', function () {
      expect(
        this.$(selectors.bunsen.collapsible.handle),
        'does not render collapsible handle'
      )
        .to.have.length(0)

      expect(
        this.$(selectors.bunsen.renderer.text),
        'renders a bunsen text input'
      )
        .to.have.length(1)

      expect(
        findTextInputs(),
        'renders one text input'
      )
        .to.have.length(1)

      expectTextInputWithState('bunsenForm-foo-input', {
        placeholder: ''
      })

      expect(
        this.$(selectors.bunsen.label).text().trim(),
        'renders expected label text'
      )
        .to.equal('Foo')

      expect(
        this.$(selectors.error),
        'does not have any validation errors'
      )
        .to.have.length(0)

      expect(
        props.onValidation.callCount,
        'informs consumer of validation results'
      )
        .to.equal(1)

      const validationResult = props.onValidation.lastCall.args[0]

      expect(
        validationResult.errors.length,
        'informs consumer there are no errors'
      )
        .to.equal(0)

      expect(
        validationResult.warnings.length,
        'informs consumer there are no warnings'
      )
        .to.equal(0)
    })
Beispiel #7
0
      it('renders as expected', function () {
        expect(
          this.$(selectors.bunsen.renderer.text),
          'renders a bunsen text input'
        )
          .to.have.length(1)

        expect(
          findTextInputs(),
          'renders one text input'
        )
          .to.have.length(1)

        const $input = this.$(selectors.frost.text.type.date.input.enabled)

        // TODO: figure out why hook doesn't work when type isn't text
        expectTextInputWithState($input, {
          placeholder: ''
          // type: 'date' // TODO: figure out why this fails
        })

        expect(
          this.$(selectors.bunsen.label).text().trim(),
          'renders expected label text'
        )
          .to.equal('Foo')

        expect(
          this.$(selectors.error),
          'does not have any validation errors'
        )
          .to.have.length(0)

        expect(
          props.onValidation.callCount,
          'informs consumer of validation results'
        )
          .to.equal(1)

        const validationResult = props.onValidation.lastCall.args[0]

        expect(
          validationResult.errors.length,
          'informs consumer there are no errors'
        )
          .to.equal(0)

        expect(
          validationResult.warnings.length,
          'informs consumer there are no warnings'
        )
          .to.equal(0)
      })
Beispiel #8
0
        it('functions as expected', function () {
          expect(
            this.$(selectors.bunsen.renderer.text),
            'renders a bunsen text input'
          )
            .to.have.length(1)

          expect(
            findTextInputs(),
            'renders one text input'
          )
            .to.have.length(1)

          expectTextInputWithState('bunsenForm-foo-input', {
            placeholder: '',
            value: 'Alex'
          })

          expect(
            this.$(selectors.error),
            'does not have any validation errors'
          )
            .to.have.length(0)

          expect(
            props.onChange.lastCall.args[0],
            'informs consumer of change'
          )
            .to.eql({
              foo: 'Alex'
            })

          expect(
            props.onValidation.callCount,
            'informs consumer of validation results'
          )
            .to.equal(1)

          const validationResult = props.onValidation.lastCall.args[0]

          expect(
            validationResult.errors,
            'has no validation errors'
          )
            .to.eql([])

          expect(
            validationResult.warnings,
            'has no validation warnings'
          )
            .to.eql([])
        })
Beispiel #9
0
      it('renders as expected', function () {
        expect(
          findTextInputs(),
          'renders one text input'
        )
          .to.have.length(1)

        expectTextInputWithState('bunsenForm-foo-input', {
          disabled: true
        })

        expect(
          this.$(selectors.error),
          'does not have any validation errors'
        )
          .to.have.length(0)
      })
  it('renders as expected', function () {
    expect(
      this.$(selectors.bunsen.renderer.text),
      'renders a bunsen text input'
    )
      .to.have.length(1)

    expect(
      findTextInputs(),
      'renders one text input'
    )
      .to.have.length(1)

    expectTextInputWithState('bunsenForm-foo.bar.baz-input', {
      placeholder: ''
    })

    expect(
      this.$(selectors.bunsen.label).text().trim(),
      'renders expected label text'
    )
      .to.equal('Baz')
  })
  it('renders as expected', function () {
    expectCollapsibleHandles(2)

    expect(
      this.$(selectors.bunsen.section.clearableButton),
      'renders clearable button for each input'
    )
      .to.have.length(2)

    const $headings = this.$(selectors.bunsen.section.heading)

    expect(
      $headings,
      'renders correct number of headings'
    )
      .to.have.length(2)

    expect(
      $headings.first().text().trim(),
      'renders correct heading text for first input'
    )
      .to.equal('Foo')

    expect(
      $headings.last().text().trim(),
      'renders correct heading text for second input'
    )
      .to.equal('Baz')

    expect(
      this.$(selectors.bunsen.renderer.text),
      'renders a bunsen text input'
    )
      .to.have.length(1)

    expect(
      this.$(selectors.bunsen.renderer.select),
      'renders a bunsen select input'
    )
      .to.have.length(1)

    expect(
      findTextInputs(),
      'renders one text input'
    )
      .to.have.length(1)

    expectTextInputWithState('bunsenForm-foo-input', {
      placeholder: '',
      value: ''
    })

    expect(
      $('.frost-select'),
      'renders one select input'
    )
      .to.have.length(1)

    expectSelectWithState($hook('bunsenForm-bar').find('.frost-select'), {
      text: ''
    })

    expect(
      this.$(selectors.error),
      'does not have any validation errors'
    )
      .to.have.length(0)

    expect(
      props.onValidation.callCount,
      'informs consumer of validation results'
    )
      .to.equal(1)

    const validationResult = props.onValidation.lastCall.args[0]

    expect(
      validationResult.errors.length,
      'informs consumer there are no errors'
    )
      .to.equal(0)

    expect(
      validationResult.warnings.length,
      'informs consumer there are no warnings'
    )
      .to.equal(0)
  })
        it('renders as expected', function () {
          const $headings = this.$(selectors.bunsen.section.heading)

          expect(
            $headings,
            'renders a cell heading'
          )
            .to.have.length(1)

          const headingText = $headings
            .clone().children().remove().end() // Remove required DOM to get just the heading
            .text().trim()

          expect(
            headingText,
            'renders expected heading text'
          )
            .to.equal('Foo')

          expect(
            this.$(selectors.bunsen.section.required),
            'renders required text in heading'
          )
            .to.have.length(1)

          expect(
            this.$(selectors.bunsen.renderer.text),
            'renders a bunsen text input'
          )
            .to.have.length(1)

          expect(
            findTextInputs(),
            'renders one text input'
          )
            .to.have.length(1)

          expectTextInputWithState('bunsenForm-foo.bar-input', {
            placeholder: ''
          })

          const label = this.$(selectors.bunsen.label)
            .clone().children().remove().end() // Remove required DOM to get just the heading
            .text().trim()

          expect(
            label,
            'renders expected label text'
          )
            .to.equal('Bar')

          expect(
            this.$(selectors.error),
            'does not have any validation errors'
          )
            .to.have.length(0)

          expectOnValidationState(ctx, {
            count: 3,
            errors: [
              {
                code: 'OBJECT_MISSING_REQUIRED_PROPERTY',
                params: ['bar'],
                message: 'Field is required.',
                path: '#/foo/bar',
                isRequiredError: true
              }
            ]
          })
        })
      it('renders as expected', function () {
        const $headings = this.$(selectors.bunsen.section.heading)

        expect(
          $headings,
          'renders a cell heading'
        )
          .to.have.length(1)

        const headingText = $headings
          .clone().children().remove().end() // Remove required DOM to get just the heading
          .text().trim()

        expect(
          headingText,
          'renders expected heading text'
        )
          .to.equal('Foo')

        expect(
          this.$(selectors.bunsen.section.required),
          'does not render required text in heading'
        )
          .to.have.length(0)

        expect(
          this.$(selectors.bunsen.renderer.text),
          'renders a bunsen text input'
        )
          .to.have.length(1)

        expect(
          findTextInputs(),
          'renders one text input'
        )
          .to.have.length(1)

        expectTextInputWithState('bunsenForm-foo.bar-input', {
          placeholder: ''
        })

        expect(
          this.$(selectors.bunsen.label).text().trim(),
          'renders expected label text'
        )
          .to.equal('Bar')

        expect(
          this.$(selectors.error),
          'does not have any validation errors'
        )
          .to.have.length(0)

        expect(
          props.onValidation.callCount,
          'informs consumer of validation results'
        )
          .to.equal(1)

        const validationResult = props.onValidation.lastCall.args[0]

        expect(
          validationResult.errors.length,
          'informs consumer there are no errors'
        )
          .to.equal(0)

        expect(
          validationResult.warnings.length,
          'informs consumer there are no warnings'
        )
          .to.equal(0)
      })
      it('renders as expected', function () {
        expectCollapsibleHandles(0)

        expect(
          this.$(selectors.bunsen.renderer.text),
          'renders a bunsen text input for item'
        )
          .to.have.length(1)

        expect(
          this.$(selectors.bunsen.renderer.number),
          'renders a bunsen number input for item'
        )
          .to.have.length(1)

        expect(
          findTextInputs({type: 'text'}),
          'renders one text input'
        )
          .to.have.length(1)

        expectTextInputWithState('bunsenForm-foo.0.bar-input', {
          value: 'test'
        })

        const $numberInput = this.$(selectors.frost.number.input.enabled)

        expect(
          findTextInputs({type: 'number'}),
          'renders an enabled number input for item'
        )
          .to.have.length(1)

        expect(
          $numberInput.val(),
          'renders default value for number input'
        )
          .to.equal('1.5')

        expect(
          this.$(selectors.bunsen.array.sort.handle),
          'does not render sort handle for auto added array item'
        )
          .to.have.length(0)

        const $buttons = this.$(selectors.frost.button.input.enabled)

        expect(
          $buttons,
          'has an enabled button for removing item plus one'
        )
          .to.have.length(2)

        expectButtonWithState($buttons.eq(0), {
          text: 'Remove'
        })

        expectButtonWithState($buttons.eq(1), {
          icon: 'round-add',
          text: 'Add foo'
        })

        expect(
          this.$(selectors.error),
          'does not have any validation errors'
        )
          .to.have.length(0)

        expectOnValidationState(ctx, {count: 2})
      })