Sha256: d859be23faa906e518c005c477593d73df8b9bea1e8ab04817a70ce56a94dbb3

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true

RSpec.describe TTY::Pie, '#add' do
  it "adds additional item" do
    data = [ { name: 'BTC', value: 5977, fill: '*' } ]

    pie = TTY::Pie.new(data: data, radius: 2)
    pie << { name: 'BCH', value: 3045, fill: '+' }
    pie << { name: 'LTC', value: 2030, fill: 'x' }

    output = pie.draw

    expect(output).to eq([
      "   x**       * BTC 54.08%\n",
      " +xx****\n",
      "++++*****    + BCH 27.55%\n",
      " +++****\n",
      "   +**       x LTC 18.37%\n"
    ].join)
  end

  it "adds item without modifying original data source" do
    data = [ { name: 'BTC', value: 5977, fill: '*' } ]
    pie = TTY::Pie.new(data: data, radius: 2)
    pie << { name: 'BCH', value: 3045, fill: '+' }

    expect(data).to match([a_hash_including(name: 'BTC')])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tty-pie-0.1.0 spec/unit/add_spec.rb