Skip to content

Commit

Permalink
ref: ApiStroke.ToJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Yar04ek authored and askonev committed Jan 19, 2024
1 parent f1b8c5e commit 94f7b19
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions spec/docx/smoke/api_stroke_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@

it 'ApiStroke | ToJSON method' do
docx = builder.build_and_parse('js/docx/smoke/api_stroke/to_json.js')
expect(docx.elements.first.nonempty_runs.first.alternate_content.office2010_content.graphic.data.text_body.elements.first.character_style_array.size).to eq(2)
expect(docx.elements.first.nonempty_runs.first.alternate_content.office2010_content.graphic.type).to eq(:shape)
expect(docx.elements[1].nonempty_runs.first.text).to include('"type":"stroke"')
stroke = JSON.parse(docx.elements[1].nonempty_runs.first.text)['graphic']['spPr']['ln']
expect(stroke['w']).to be_a(Integer)
expect(stroke['algn']).to be_nil
expect(stroke['fill']['fill']['color']['color']['rgba']['red']).to eq(51)
expect(stroke['fill']['fill']['color']['color']['rgba']['green']).to eq(51)
expect(stroke['fill']['fill']['color']['color']['rgba']['blue']).to eq(51)
expect(stroke['fill']['fill']['color']['color']['rgba']['alpha']).to eq(255)
expect(stroke['w']).to eq(180_000)
expect(OoxmlParser::Color.new(stroke['fill']['fill']['color']['color']['rgba']['red'],
stroke['fill']['fill']['color']['color']['rgba']['green'],
stroke['fill']['fill']['color']['color']['rgba']['blue']).to_hex.to_sym)
.to eq(OoxmlParser::Color.new(51, 51, 51).to_hex.to_sym)
expect(stroke['fill']['fill']['type']).to eq('solid')
expect(stroke['fill']['transparent']).to be_nil
expect(stroke['transparent']).to be_nil
expect(stroke['type']).to eq('stroke')
expect(docx.elements[1].nonempty_runs.first.text).to include('"type":"stroke"')
end
end

0 comments on commit 94f7b19

Please sign in to comment.