Sha256: b96038026a0232a487759881f4a78563cba3ae24d7fc1e9b6bc5943d15f03eb7

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'action_view'

RSpec.describe CKEditor5::Rails::Context::Helpers do
  let(:test_class) do
    Class.new do
      include ActionView::Helpers::TagHelper
      include CKEditor5::Rails::Context::Helpers
    end
  end

  let(:helper) { test_class.new }

  describe '#ckeditor5_context' do
    it 'creates context component with default attributes' do
      expect(helper.ckeditor5_context).to have_tag(
        'ckeditor-context-component',
        with: {
          plugins: '[]',
          config: '{}'
        }
      )
    end

    it 'creates context component with preset configuration' do
      expect(helper.ckeditor5_context(preset: :custom)).to have_tag(
        'ckeditor-context-component',
        with: {
          plugins: '[]',
          config: '{"preset":"custom"}'
        }
      )
    end

    it 'creates context component with cdn configuration' do
      expect(helper.ckeditor5_context(cdn: :jsdelivr)).to have_tag(
        'ckeditor-context-component',
        with: {
          plugins: '[]',
          config: '{"cdn":"jsdelivr"}'
        }
      )
    end

    it 'creates context component with multiple configurations' do
      result = helper.ckeditor5_context(preset: :custom, cdn: :jsdelivr)

      expect(result).to have_tag(
        'ckeditor-context-component',
        with: {
          plugins: '[]',
          config: '{"preset":"custom","cdn":"jsdelivr"}'
        }
      )
    end

    it 'accepts block content' do
      result = helper.ckeditor5_context { 'Content' }

      expect(result).to have_tag('ckeditor-context-component') do
        with_text 'Content'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ckeditor5-1.16.1 spec/lib/ckeditor5/rails/context/helpers_spec.rb
ckeditor5-1.16.0 spec/lib/ckeditor5/rails/context/helpers_spec.rb
ckeditor5-1.15.10 spec/lib/ckeditor5/rails/context/helpers_spec.rb
ckeditor5-1.15.9 spec/lib/ckeditor5/rails/context/helpers_spec.rb