Skip to content

Commit

Permalink
ref: ApiRGBColorToJson
Browse files Browse the repository at this point in the history
  • Loading branch information
Yar04ek committed Nov 30, 2023
1 parent 82cfde0 commit d10e24a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 5 additions & 6 deletions js/docx/smoke/api_rgb_color/to_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ builder.CreateFile("docx");
let oParagraph = oDocument.GetElement(0);
let oRGBColor = Api.CreateRGBColor(255, 111, 61);
let jsonRGBColor = oRGBColor.ToJSON();
oParagraph.AddText(jsonRGBColor);
GlobalVariable["JSON_RGBColor"] = jsonRGBColor;
oParagraph.AddText(jsonRGBColor);
GlobalVariable["JSON_RGBColor"] = jsonRGBColor;
builder.CloseFile();

/////////////////////
Expand All @@ -17,8 +17,9 @@ builder.CreateFile("docx");
oParagraph1.AddText(jsonRGBColor);
oDocument.Push(oParagraph1);
let oParagraph2 = Api.CreateParagraph();
let oGs1 = Api.CreateGradientStop(oRGBColor, 0);
let oGs2 = Api.CreateGradientStop(oRGBColor, 10);
let oRGBColor2 = Api.CreateRGBColor(255, 111, 61);
let oGs1 = Api.CreateGradientStop(oRGBColor2, 0);
let oGs2 = Api.CreateGradientStop(oRGBColor2, 10);
let oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 5400000);
let oStroke = Api.CreateStroke(0, Api.CreateNoFill());
let oDrawing = Api.CreateShape("rect", 5930900, 395605, oFill, oStroke);
Expand All @@ -27,5 +28,3 @@ builder.CreateFile("docx");
oDocument.Push(oParagraph2);
builder.SaveFile("docx", "RGBCoolorToJson.docx");
builder.CloseFile();


6 changes: 2 additions & 4 deletions spec/docx/smoke/api_rgb_color_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

it 'ApiRGBColor | ToJSON method' do
docx = builder.build_and_parse('js/docx/smoke/api_rgb_color/to_json.js')
first_paragraph_text = docx.elements[0].nonempty_runs.first.text
second_paragraph_text = docx.elements[1].nonempty_runs.first.text
first_paragraph_json = JSON.parse(first_paragraph_text)
second_paragraph_json = JSON.parse(second_paragraph_text)
first_paragraph_json = JSON.parse(docx.elements[0].nonempty_runs.first.text)
second_paragraph_json = JSON.parse(docx.elements[1].nonempty_runs.first.text)
expect(second_paragraph_json.to_s).to include(first_paragraph_json.to_s)
end
end

0 comments on commit d10e24a

Please sign in to comment.