# frozen_string_literal: true RSpec.describe DiscourseAi::Utils::DiffUtils::SafetyChecker do describe "#safe?" do subject { described_class.new(text).safe? } context "with safe text" do let(:text) { "This is a simple safe text without issues." } it { is_expected.to eq(true) } context "with normal HTML tags" do let(:text) { "Here is bold and italic text." } it { is_expected.to eq(true) } end context "with balanced markdown and no partial emoji" do let(:text) { "This is **bold**, *italic*, and a smiley :smile:!" } it { is_expected.to eq(true) } end context "with balanced quote blocks" do let(:text) { "[quote]Quoted text[/quote]" } it { is_expected.to eq(true) } end context "with complete image markdown" do let(:text) { "![alt text](https://example.com/image.png)" } it { is_expected.to eq(true) } end end context "with unsafe text" do context "with unclosed markdown link" do let(:text) { "This is a [link(https://example.com)" } it { is_expected.to eq(false) } end context "with unclosed raw HTML tag" do let(:text) { "Text with