discourse/spec/components/discourse_plugin_registry_s...

86 lines
2.2 KiB
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
require 'spec_helper'
require 'discourse_plugin_registry'
describe DiscoursePluginRegistry do
2014-04-01 01:08:18 -04:00
class TestRegistry < DiscoursePluginRegistry; end
let(:registry) { TestRegistry }
let(:registry_instance) { registry.new }
2013-02-25 11:42:20 -05:00
2013-02-08 02:56:12 -05:00
context '#stylesheets' do
it 'defaults to an empty Set' do
2014-04-01 01:08:18 -04:00
registry.stylesheets = nil
registry.stylesheets.should == Set.new
2013-02-08 02:56:12 -05:00
end
end
context '#mobile_stylesheets' do
it 'defaults to an empty Set' do
registry.mobile_stylesheets = nil
registry.mobile_stylesheets.should == Set.new
end
end
2013-02-08 02:56:12 -05:00
context '#javascripts' do
it 'defaults to an empty Set' do
2014-04-01 01:08:18 -04:00
registry.javascripts = nil
registry.javascripts.should == Set.new
2013-02-08 02:56:12 -05:00
end
end
context '#server_side_javascripts' do
it 'defaults to an empty Set' do
2014-04-01 01:08:18 -04:00
registry.server_side_javascripts = nil
registry.server_side_javascripts.should == Set.new
end
end
context '#admin_javascripts' do
it 'defaults to an empty Set' do
2014-04-01 01:08:18 -04:00
registry.admin_javascripts = nil
registry.admin_javascripts.should == Set.new
2013-02-08 02:56:12 -05:00
end
end
2013-02-05 14:16:51 -05:00
context '.register_css' do
before do
2014-04-01 01:08:18 -04:00
registry_instance.register_css('hello.css')
end
it 'is not leaking' do
DiscoursePluginRegistry.new.stylesheets.should be_blank
2013-02-05 14:16:51 -05:00
end
it 'is returned by DiscoursePluginRegistry.stylesheets' do
2014-04-01 01:08:18 -04:00
registry_instance.stylesheets.include?('hello.css').should be_true
2013-02-05 14:16:51 -05:00
end
it "won't add the same file twice" do
2014-04-01 01:08:18 -04:00
lambda { registry_instance.register_css('hello.css') }.should_not change(registry.stylesheets, :size)
2013-02-25 11:42:20 -05:00
end
2013-02-05 14:16:51 -05:00
end
context '.register_js' do
before do
2014-04-01 01:08:18 -04:00
registry_instance.register_js('hello.js')
2013-02-05 14:16:51 -05:00
end
it 'is returned by DiscoursePluginRegistry.javascripts' do
2014-04-01 01:08:18 -04:00
registry_instance.javascripts.include?('hello.js').should be_true
2013-02-05 14:16:51 -05:00
end
it "won't add the same file twice" do
2014-04-01 01:08:18 -04:00
lambda { registry_instance.register_js('hello.js') }.should_not change(registry.javascripts, :size)
2013-02-25 11:42:20 -05:00
end
2013-02-05 14:16:51 -05:00
end
context '.register_archetype' do
it "delegates archetypes to the Archetype component" do
Archetype.expects(:register).with('threaded', hello: 123)
2014-04-01 01:08:18 -04:00
registry_instance.register_archetype('threaded', hello: 123)
2013-02-05 14:16:51 -05:00
end
end
end