REFACTOR: Migrate markdown functionality in ES6

This commit is contained in:
Robin Ward
2016-06-14 14:31:51 -04:00
parent bc25d9a7a0
commit a546395397
146 changed files with 3259 additions and 5675 deletions

View File

@@ -59,7 +59,8 @@ describe CookedPostProcessor do
context "valid" do
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 111, "height" => 222}} }
it "use them" do
it "uses them" do
# adds the width from the image sizes provided when no dimension is provided
expect(cpp.html).to match(/src="http:\/\/foo.bar\/image.png" width="111" height="222"/)
# adds the width from the image sizes provided

View File

@@ -29,13 +29,6 @@ describe DiscoursePluginRegistry do
end
end
context '#server_side_javascripts' do
it 'defaults to an empty Set' do
registry.server_side_javascripts = nil
expect(registry.server_side_javascripts).to eq(Set.new)
end
end
context '#admin_javascripts' do
it 'defaults to an empty Set' do
registry.admin_javascripts = nil
@@ -139,15 +132,6 @@ describe DiscoursePluginRegistry do
expect(registry.admin_javascripts.count).to eq(1)
expect(registry.javascripts.count).to eq(0)
expect(registry.server_side_javascripts.count).to eq(0)
end
it "registers server side javascript properly" do
registry.register_asset("my_admin.js", :server_side)
expect(registry.server_side_javascripts.count).to eq(1)
expect(registry.javascripts.count).to eq(1)
expect(registry.admin_javascripts.count).to eq(0)
end
end

View File

@@ -133,16 +133,13 @@ describe Plugin::Instance do
plugin.register_asset("code.js")
plugin.register_asset("server_side.js", :server_side)
plugin.register_asset("my_admin.js", :admin)
plugin.register_asset("my_admin2.js", :admin)
plugin.activate!
expect(DiscoursePluginRegistry.javascripts.count).to eq(3)
expect(DiscoursePluginRegistry.javascripts.count).to eq(2)
expect(DiscoursePluginRegistry.admin_javascripts.count).to eq(2)
expect(DiscoursePluginRegistry.server_side_javascripts.count).to eq(1)
expect(DiscoursePluginRegistry.desktop_stylesheets.count).to eq(2)
expect(DiscoursePluginRegistry.sass_variables.count).to eq(2)
expect(DiscoursePluginRegistry.stylesheets.count).to eq(2)

View File

@@ -376,21 +376,11 @@ HTML
end
describe 'tables' do
before do
PrettyText.reset_context
end
after do
PrettyText.reset_context
end
it 'allows table html' do
SiteSetting.allow_html_tables = true
PrettyText.reset_context
table = "<table class='fa-spin'><thead><tr>\n<th class='fa-spin'>test</th></tr></thead><tbody><tr><td>a</td></tr></tbody></table>"
match = "<table class=\"md-table\"><thead><tr> <th>test</th> </tr></thead><tbody><tr><td>a</td></tr></tbody></table>"
expect(PrettyText.cook(table)).to match_html(match)
end
it 'allows no tables when not enabled' do
@@ -424,14 +414,19 @@ HTML
end
describe "tag and category links" do
it "produces tag links" do
Fabricate(:topic, {tags: [Fabricate(:tag, name: 'known')]})
expect(PrettyText.cook(" #unknown::tag #known::tag")).to match_html("<p> <span class=\"hashtag\">#unknown::tag</span> <a class=\"hashtag\" href=\"http://test.localhost/tags/known\">#<span>known</span></a></p>")
end
# TODO does it make sense to generate hashtags for tags that are missing in action?
end
describe "custom emoji" do
it "replaces the custom emoji" do
Emoji.stubs(:custom).returns([ Emoji.create_from_path('trout') ])
expect(PrettyText.cook("hello :trout:")).to match(/<img src[^>]+trout[^>]+>/)
end
end
end

View File

@@ -369,6 +369,7 @@ describe Post do
end
it "finds links from HTML" do
expect(post_two_links.link_count).to eq(2)
end