expectSuggestorGeneratesPatches function

void expectSuggestorGeneratesPatches(
  1. Suggestor suggestor,
  2. FileContext context,
  3. 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));
}