mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Feature: Add service worker registration method to plugin API
This commit is contained in:
@@ -92,6 +92,25 @@ describe DiscoursePluginRegistry do
|
||||
end
|
||||
end
|
||||
|
||||
context '.register_service_worker' do
|
||||
let(:registry) { DiscoursePluginRegistry }
|
||||
|
||||
before do
|
||||
registry.register_service_worker('hello.js')
|
||||
end
|
||||
|
||||
after do
|
||||
registry.reset!
|
||||
end
|
||||
|
||||
it "should register the file once" do
|
||||
2.times { registry.register_service_worker('hello.js') }
|
||||
|
||||
expect(registry.service_workers.size).to eq(1)
|
||||
expect(registry.service_workers).to include('hello.js')
|
||||
end
|
||||
end
|
||||
|
||||
context '.register_archetype' do
|
||||
it "delegates archetypes to the Archetype component" do
|
||||
Archetype.expects(:register).with('threaded', hello: 123)
|
||||
|
||||
@@ -95,6 +95,18 @@ describe Plugin::Instance do
|
||||
end
|
||||
end
|
||||
|
||||
context "register service worker" do
|
||||
it "populates the DiscoursePluginRegistry" do
|
||||
plugin = Plugin::Instance.new nil, "/tmp/test.rb"
|
||||
plugin.register_service_worker("test.js")
|
||||
plugin.register_service_worker("test2.js")
|
||||
|
||||
plugin.send :register_service_workers!
|
||||
|
||||
expect(DiscoursePluginRegistry.service_workers.count).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context "activate!" do
|
||||
it "can activate plugins correctly" do
|
||||
plugin = Plugin::Instance.new
|
||||
|
||||
Reference in New Issue
Block a user