Sha256: 8f55842afe1501dbf3bd5837e1ecb4aa166c581801ca036d8784af34618b3492

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe CKEditor5::Rails::Editor::PropsExternalPlugin do
  describe '#initialize' do
    it 'creates plugin with required parameters' do
      plugin = described_class.new('Test', script: 'https://example.org/plugin.js')

      expect(plugin.name).to eq('Test')
      expect(plugin.preload_assets_bundle.scripts.first.url).to eq('https://example.org/plugin.js')
    end

    it 'accepts optional parameters' do
      plugin = described_class.new(
        'Test',
        script: 'https://example.org/plugin.js',
        import_as: 'TestPlugin',
        window_name: 'TestWindow',
        stylesheets: ['https://example.org/style.css']
      )

      expect(plugin.preload_assets_bundle.stylesheets).to include('https://example.org/style.css')
    end
  end

  describe '#preload_assets_bundle' do
    it 'returns bundle with script and stylesheets' do
      plugin = described_class.new(
        'Test',
        script: 'https://example.org/plugin.js',
        stylesheets: ['https://example.org/style1.css', 'https://example.org/style2.css']
      )

      bundle = plugin.preload_assets_bundle
      expect(bundle.scripts.first.url).to eq('https://example.org/plugin.js')
      expect(bundle.stylesheets).to eq(['https://example.org/style1.css', 'https://example.org/style2.css'])
    end
  end

  describe '#to_h' do
    it 'returns hash with plugin configuration' do
      plugin = described_class.new(
        'Test',
        script: 'https://example.org/plugin.js',
        import_as: 'TestPlugin',
        window_name: 'TestWindow',
        stylesheets: ['https://example.org/style.css']
      )

      expect(plugin.to_h).to include(
        import_name: 'https://example.org/plugin.js',
        import_as: 'TestPlugin',
        window_name: 'TestWindow',
        stylesheets: ['https://example.org/style.css']
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/ckeditor5-1.24.9/spec/lib/ckeditor5/rails/editor/props_external_plugin_spec.rb
ckeditor5-1.24.9 spec/lib/ckeditor5/rails/editor/props_external_plugin_spec.rb
ckeditor5-1.24.8 spec/lib/ckeditor5/rails/editor/props_external_plugin_spec.rb
ckeditor5-1.24.6 spec/lib/ckeditor5/rails/editor/props_external_plugin_spec.rb