# frozen_string_literal: true

RSpec.describe Normalizy::Filters::Slug do
  describe 'default options' do
    it { expect(subject.call(nil)).to be(nil) }
    it { expect(subject.call('')).to  eq '' }

    it { expect(subject.call('The Title')).to eq 'the-title' }
  end

  describe 'to' do
    it { expect(subject.call(nil, to: :slug)).to be(nil) }
    it { expect(subject.call('', to: :slug)).to eq '' }
    it { expect(subject.call('The Title', to: :slug)).to eq 'the-title' }

    context 'when is not :to key' do
      it { expect(subject.call(nil, from: :slug)).to be(nil) }
      it { expect(subject.call('', from: :slug)).to eq '' }
      it { expect(subject.call('The Title', from: :slug)).to eq 'the-title' }
    end
  end
end
