Skip to content

Commit

Permalink
Another attempt to make the test work cross platform
Browse files Browse the repository at this point in the history
  • Loading branch information
michalt committed Sep 24, 2020
1 parent b0d81fb commit dd23dc4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pkgs/watcher/test/custom_watcher_factory_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'dart:async';
import 'package:test/test.dart';
import 'package:watcher/watcher.dart';

import 'utils.dart';

void main() {
_MemFs memFs;
final defaultFactoryId = 'MemFs';
Expand Down Expand Up @@ -45,16 +47,18 @@ void main() {
test('unregister works', () async {
unregisterCustomWatcherFactory(defaultFactoryId);

var events = <WatchEvent>[];
var watcher = FileWatcher('file.txt');
watcher.events.listen((e) => events.add(e));
await watcher.ready;
memFs.add('a.txt');
memFs.add('b.txt');
memFs.add('c.txt');
await Future.delayed(Duration(seconds: 1));
watcherFactory = (path) => FileWatcher(path);
try {
// This uses standard files, so it wouldn't trigger an event in
// _MemFsWatcher.
writeFile('file.txt');
await startWatcher(path: 'file.txt');
deleteFile('file.txt');
} finally {
watcherFactory = null;
}

expect(events, isEmpty);
await expectRemoveEvent('file.txt');
});

test('registering twice throws', () async {
Expand Down

0 comments on commit dd23dc4

Please sign in to comment.