Sha256: 2a189d5de4fcbdf991b40216008548ea299746e92d767e58b4d669f5e1b987dc
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true RSpec.describe TTY::Pie, ':legend option' do it "draws legend at default location with 1 line separator" do data = [ { name: 'BTC', value: 5977, fill: '*' }, { name: 'BCH', value: 3045, fill: '+' }, { name: 'LTC', value: 2030, fill: 'x' } ] pie = TTY::Pie.new(data: data, radius: 2) 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 "draws legend next to chart without any line separator" do data = [ { name: 'BTC', value: 5977, fill: '*' }, { name: 'BCH', value: 3045, fill: '+' }, { name: 'LTC', value: 2030, fill: 'x' } ] pie = TTY::Pie.new(data: data, radius: 2, legend: {left: 0, line: 0}) output = pie.draw expect(output).to eq([ " x**\n", " +xx**** * BTC 54.08%\n", "++++*****+ BCH 27.55%\n", " +++**** x LTC 18.37%\n", " +**\n" ].join) end it "draws legend at custom location with line separator" do data = [ { name: 'BTC', value: 5977, fill: '*' }, { name: 'BCH', value: 3045, fill: '+' }, { name: 'LTC', value: 2030, fill: 'x' } ] pie = TTY::Pie.new(data: data, radius: 3, legend: {left: 10, line: 2}) output = pie.draw expect(output).to eq([ " x** * BTC 54.08%\n", " xxxx*****\n", "++++xx*******\n", "++++++******* + BCH 27.55%\n", "++++++*******\n", " ++++*****\n", " +** x LTC 18.37%\n" ].join) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tty-pie-0.1.0 | spec/unit/legend_spec.rb |