Sha256: 02747a4ab2b32e1088d23e3b0bf990ba018dbbc615b1d32560907b0adbcb3791

Contents?: true

Size: 962 Bytes

Versions: 10

Compression:

Stored size: 962 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/document'
require 'hexapdf/type/annotation'

describe HexaPDF::Type::Annotation do
  before do
    @doc = HexaPDF::Document.new
    @annot = @doc.add({Type: :Annot, F: 0b100011})
  end

  describe "flags" do
    it "returns all flags" do
      assert_equal([:invisible, :hidden, :no_view], @annot.flags)
    end
  end

  describe "flagged?" do
    it "returns true if the given flag is set" do
      assert(@annot.flagged?(:hidden))
      refute(@annot.flagged?(:locked))
    end

    it "raises an error if an unknown flag name is provided" do
      assert_raises(ArgumentError) { @annot.flagged?(:unknown) }
    end
  end

  describe "flag" do
    it "sets the given flag bits" do
      @annot.flag(:locked)
      assert_equal([:invisible, :hidden, :no_view, :locked], @annot.flags)
      @annot.flag(:locked, clear_existing: true)
      assert_equal([:locked], @annot.flags)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hexapdf-0.11.9 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.8 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.7 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.6 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.5 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.4 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.3 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.2 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.1 test/hexapdf/type/test_annotation.rb
hexapdf-0.11.0 test/hexapdf/type/test_annotation.rb