firebase_cloud_functions_mock 0.0.2 copy "firebase_cloud_functions_mock: ^0.0.2" to clipboard
firebase_cloud_functions_mock: ^0.0.2 copied to clipboard

outdated

Dart firebase cloud functioin mock for testing

firebase_cloud_functions_mock #

Dart firebase cloud functioin mock for testing

Getting Started #

-- USE

import 'package:firebase_cloud_functions_mock/firebase_cloud_functions_mock.dart';
final mockCloudFunction = new MockCloudFunctions();
mockCloudFunction.mockResult(
  functionName: 'getHelloword',
  json: '''{"helloword": "ok"}'''
);

//in repository
//make sure the CloudFunctions instance is replaced by the mocking one in the testing environment

bool isTest = true;
class HelloRepository{
  CloudFunctions cloudFunc;
  HelloRepository(): isTest ? mockCloudFunction : CloudFunctions(
  )

  HttpsCallableResult result = cloudFunc.getHttpsCallable(functionName: 'getHelloword')
      .call(<String, dynamic>{
  });
  print(result);
  //result should be Map<String, dynamic>{} {"helloword": "ok"}

}