spec/dom/mutation_observer_spec.rb in opal-browser-0.2.0 vs spec/dom/mutation_observer_spec.rb in opal-browser-0.3.0
- old
+ new
@@ -5,33 +5,37 @@
<div id="mutate">
<span></span>
</div>
HTML
- async 'notifies additions' do
+ it 'notifies additions' do
+ promise = Browser::Promise.new
obs = Browser::DOM::MutationObserver.new {|mutations|
- async {
- expect(mutations.first.added.first.name).to eq('DIV')
- }
+ expect(mutations.first.added.first.name).to eq('DIV')
+ promise.resolve
obs.disconnect
}
obs.observe $document[:mutate]
$document[:mutate].add_child $document.create_element('div')
+
+ promise.for_rspec
end
- async 'notifies removals' do
+ it 'notifies removals' do
+ promise = Browser::Promise.new
obs = Browser::DOM::MutationObserver.new {|mutations|
- async {
- expect(mutations.first.removed.first.name).to eq('SPAN')
- }
+ expect(mutations.first.removed.first.name).to eq('SPAN')
+ promise.resolve
obs.disconnect
}
obs.observe $document[:mutate]
$document[:mutate].first_element_child.remove
+
+ promise.for_rspec
end
end if Browser::DOM::MutationObserver.supported?