it('renders as expected', function () {
        expectCollapsibleHandles(0, 'bunsenDetail')

        expect(
          this.$(selectors.bunsen.renderer.text),
          'does not render any bunsen text inputs'
        )
          .to.have.length(0)

        expect(
          findTextInputs(),
          'does not render any text inputs'
        )
          .to.have.length(0)

        expect(
          this.$(selectors.bunsen.array.sort.handle),
          'does not render any sort handles'
        )
          .to.have.length(0)

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

        expect(
          $button,
          'does not have any buttons'
        )
          .to.have.length(0)

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

        const $emptyMsg = this.$(selectors.bunsen.array.emptyMsg)

        expect(
          $emptyMsg,
          'has empty array message'
        )
          .to.have.length(1)

        expect(
          $emptyMsg.text().trim(),
          'has empty array message'
        )
          .to.equal('List is currently empty.')
      })
Ejemplo n.º 2
0
  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.bar-input', {
      placeholder: '',
      value: 'test1'
    })

    expectTextInputWithState('bunsenForm-foo.0.baz.spam.alpha-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('Bar')

    expect(
      $labels.last().text().trim(),
      'renders expected label text'
    )
      .to.equal('Alpha')
  })
  it('renders as expected', function () {
    expectCollapsibleHandles(0)

    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)
  })