Compare commits
4 commits
ee9d512c1f
...
931695b22e
Author | SHA1 | Date | |
---|---|---|---|
|
931695b22e | ||
|
ae41dbf55d | ||
|
2e4e153b4f | ||
|
fadcffdc25 |
|
@ -328,6 +328,15 @@ class Dispatcher implements DispatcherContract {
|
|||
_transactionManagerResolver = resolver;
|
||||
}
|
||||
|
||||
// Add these methods for testing purposes
|
||||
void triggerQueueResolver() {
|
||||
_queueResolver();
|
||||
}
|
||||
|
||||
void triggerTransactionManagerResolver() {
|
||||
_transactionManagerResolver();
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, List<Function>> getRawListeners() {
|
||||
return Map.unmodifiable(_listeners);
|
||||
|
|
|
@ -147,6 +147,57 @@ void main() {
|
|||
expect(mockMQClient.queuedMessages['events_queue']!.first.payload,
|
||||
containsPair('event', 'QueueTestEvent'));
|
||||
});
|
||||
|
||||
test('forgetPushed removes only pushed events', () {
|
||||
dispatcher.listen('event_pushed', (_, __) {});
|
||||
dispatcher.listen('normal_event', (_, __) {});
|
||||
|
||||
dispatcher.forgetPushed();
|
||||
|
||||
expect(dispatcher.hasListeners('event_pushed'), isFalse);
|
||||
expect(dispatcher.hasListeners('normal_event'), isTrue);
|
||||
});
|
||||
|
||||
test('setQueueResolver and setTransactionManagerResolver', () {
|
||||
var queueResolverCalled = false;
|
||||
var transactionManagerResolverCalled = false;
|
||||
|
||||
dispatcher.setQueueResolver(() {
|
||||
queueResolverCalled = true;
|
||||
});
|
||||
|
||||
dispatcher.setTransactionManagerResolver(() {
|
||||
transactionManagerResolverCalled = true;
|
||||
});
|
||||
|
||||
// Trigger the resolvers
|
||||
dispatcher.triggerQueueResolver();
|
||||
dispatcher.triggerTransactionManagerResolver();
|
||||
|
||||
expect(queueResolverCalled, isTrue);
|
||||
expect(transactionManagerResolverCalled, isTrue);
|
||||
});
|
||||
|
||||
test('getRawListeners returns unmodifiable map', () {
|
||||
dispatcher.listen('test_event', (_, __) {});
|
||||
var rawListeners = dispatcher.getRawListeners();
|
||||
|
||||
expect(rawListeners, isA<Map<String, List<Function>>>());
|
||||
expect(() => rawListeners['new_event'] = [], throwsUnsupportedError);
|
||||
});
|
||||
|
||||
test('multiple listeners for same event', () async {
|
||||
var callCount1 = 0;
|
||||
var callCount2 = 0;
|
||||
|
||||
dispatcher.listen('multi_event', (_, __) => callCount1++);
|
||||
dispatcher.listen('multi_event', (_, __) => callCount2++);
|
||||
|
||||
await dispatcher.dispatch('multi_event');
|
||||
|
||||
expect(callCount1, equals(1));
|
||||
expect(callCount2, equals(1));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ repository: https://github.com/protevus/platform
|
|||
packages:
|
||||
- core/**
|
||||
- packages/**
|
||||
- sandbox/**
|
||||
- wspace/**
|
||||
- examples/**
|
||||
|
||||
command:
|
||||
|
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |