Sha256: a260674e3129551c21accdef08f05ad286dcdfb7bd698ef518fab052c141d485

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe CKEditor5::Rails::Editor::PropsInlinePlugin do
  let(:valid_code) do
    <<~JAVASCRIPT
      const { Plugin } = await import( 'ckeditor5' );

      return class CustomPlugin extends Plugin {
        init() {
          console.log('Custom plugin initialized');
        }
      }
    JAVASCRIPT
  end

  describe '#initialize' do
    it 'accepts valid plugin code' do
      expect { described_class.new(:CustomPlugin, valid_code) }.not_to raise_error
    end

    it 'raises error when code is not a string' do
      expect { described_class.new(:CustomPlugin, nil) }
        .to raise_error(ArgumentError, 'Code must be a String')
    end
  end

  describe '#to_h' do
    it 'returns correct hash representation' do
      plugin = described_class.new(:CustomPlugin, valid_code)
      expect(plugin.to_h).to eq({
                                  type: :external,
                                  window_name: :CustomPlugin
                                })
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ckeditor5-1.24.1 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.24.0 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb