Skip to content

Commit c18c9d9

Browse files
HassanAkbarronaldtse
authored andcommitted
added and fixed test cases
1 parent f605de8 commit c18c9d9

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

spec/iev/termbase/source_parser_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
subject do
88
example = RSpec.current_example
99
attributes_str = example.metadata[:string] || example.description
10-
described_class.new(attributes_str)
10+
described_class.new(attributes_str, "IEV")
1111
end
1212

1313
around do |example|
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# frozen_string_literal: true
2+
3+
require "spec_helper"
4+
5+
class TestUtilites
6+
include IEV::Termbase::Utilities
7+
end
8+
9+
RSpec.describe IEV::Termbase::Utilities do
10+
subject { TestUtilites.new }
11+
12+
describe "#parse_anchor_tag" do
13+
context "when end tag is present" do
14+
it "converts the a tag with quotes to asciidoc format" do
15+
text = "See <a href=\"IEV121-02-02\">121-02-02</a>"
16+
17+
expect(subject.parse_anchor_tag(text, "IEV"))
18+
.to eq("See {{121-02-02, IEV:121-02-02}}")
19+
end
20+
21+
it "converts the a tag with quotes to asciidoc format" do
22+
text = "See <a href=IEV121-02-03>121-02-03</a>"
23+
24+
expect(subject.parse_anchor_tag(text, "IEV"))
25+
.to eq("See {{121-02-03, IEV:121-02-03}}")
26+
end
27+
end
28+
29+
context "when end tag is not present" do
30+
it "converts the a tag with quotes to asciidoc format" do
31+
text = "See <a href=\"IEV121-02-02\">No end tag"
32+
33+
expect(subject.parse_anchor_tag(text, "IEV"))
34+
.to eq("See {{No end tag, IEV:121-02-02}}")
35+
end
36+
37+
it "converts the a tag with quotes to asciidoc format" do
38+
text = "See <a href=IEV121-02-03>No end tag"
39+
40+
expect(subject.parse_anchor_tag(text, "IEV"))
41+
.to eq("See {{No end tag, IEV:121-02-03}}")
42+
end
43+
end
44+
end
45+
46+
describe "#replace_newlines" do
47+
it "should replace <br> tag with newlines" do
48+
expect(subject.replace_newlines("Hello<br>world"))
49+
.to eq("Hello\n\nworld")
50+
end
51+
52+
it "should replace <p> tag with newlines" do
53+
expect(subject.replace_newlines("Hello<p>world"))
54+
.to eq("Hello\n\nworld")
55+
end
56+
57+
it "should replace \\n tag with newlines" do
58+
expect(subject.replace_newlines("Hello\\nworld"))
59+
.to eq("Hello\n\nworld")
60+
end
61+
62+
it "should replace multiple \\n tag with newlines" do
63+
expect(subject.replace_newlines("Hello\\n\\n\\n\\n\\n\\nworld"))
64+
.to eq("Hello\n\nworld")
65+
end
66+
end
67+
end

0 commit comments

Comments
 (0)