expectSuggestorGeneratesPatches function
void
expectSuggestorGeneratesPatches(
- Suggestor suggestor,
- FileContext context,
- dynamic resultMatcher
Uses suggestor
to generate a stream of patches for context
and returns
what the resulting file contents would be after applying all of them.
Use this to test that a suggestor produces the expected result: test('MySuggestor', () async { var context = await fileContextForTest('foo.dart', 'library foo;'); var suggestor = MySuggestor(); var expectedOutput = '...'; expectSuggestorGeneratesPatches(suggestor, context, expectedOutput); });
Implementation
void expectSuggestorGeneratesPatches(
Suggestor suggestor, FileContext context, dynamic resultMatcher) {
expect(
suggestor(context)
.toList()
.then((patches) => applyPatches(context.sourceFile, patches)),
completion(resultMatcher));
}