Sha256: 5b21379a5c93573397cca9cb18afac99840313f30ed5673ea31f55fb35c6fae9

Contents?: true

Size: 1.29 KB

Versions: 29

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe CKEditor5::Rails::Editor::PropsInlinePlugin do
  let(:valid_code) do
    <<~JAVASCRIPT
      import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
      export default 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

    it 'raises error when code lacks export default' do
      expect { described_class.new(:CustomPlugin, 'class CustomPlugin {}') }
        .to raise_error(ArgumentError, /must include `export default`/)
    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: :inline,
                                  name: :CustomPlugin,
                                  code: valid_code
                                })
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ckeditor5-1.23.5 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.23.4 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.23.3 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.23.2 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.23.1 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.23.0 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.22.0 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.21.0 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.20.1 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.20.0 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.19.5 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.19.4 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.19.3 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.19.2 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.19.1 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.19.0 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.18.3 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.18.1 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.18.0 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb
ckeditor5-1.17.4 spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb