Sha256: f6634c70ca1474bd369e71ba472d3021b5fbdfa3464ebca2174cc07b39857496

Contents?: true

Size: 1.56 KB

Versions: 21

Compression:

Stored size: 1.56 KB

Contents

require 'test_helper'

module Vedeu

  module Renderers

    describe JSON do

      let(:described) { Vedeu::Renderers::JSON }
      let(:instance)  { described.new(output) }
      let(:output)    {}

      describe '#initialize' do
        it { instance.must_be_instance_of(described) }
        it { instance.instance_variable_get('@output').must_equal(output) }
      end

      describe '.render' do
        subject { described.render(output) }

        it { subject.must_be_instance_of(String) }

        context 'when the output is empty' do
          it { subject.must_equal('') }
        end

        context 'when the output is not empty' do
          let(:colour) {
            Vedeu::Colour.new(foreground: '#ff0000', background: '#ffffff')
          }
          let(:output) {
            [
              [
                Vedeu::Char.new(value: 'a',
                                colour: colour,
                                position: Vedeu::Position[5, 3])
              ]
            ]
          }
          it { subject.must_equal(
            "{\"border\":\"\",\"colour\":{\""                        \
            "background\":\"\\u001b[48;2;255;255;255m\","            \
            "\"foreground\":\"\\u001b[38;2;255;0;0m\"},"             \
            "\"parent\":{\""                                         \
            "background\":\"\",\"foreground\":\"\",\"style\":\"\"}," \
            "\"position\":{\"y\":5,\"x\":3},\"style\":\"\","         \
            "\"value\":\"a\"}\n\n"
          ) }
        end
      end

    end # JSON

  end # Renderers

end # Vedeu

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
vedeu-0.4.39 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.38 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.37 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.36 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.35 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.34 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.33 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.32 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.31 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.30 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.29 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.28 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.27 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.26 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.25 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.24 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.23 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.22 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.21 test/lib/vedeu/output/renderers/json_test.rb
vedeu-0.4.20 test/lib/vedeu/output/renderers/json_test.rb