Skip to content

Commit

Permalink
plugin: add get manifest unit test regarding the hooks
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Jul 14, 2022
1 parent 1f38f43 commit affa3b5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/cln_plugin/test/cln_plugin_method_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:convert';

import 'package:cln_plugin/src/cln_plugin_base.dart';
import 'package:test/test.dart';

Expand Down Expand Up @@ -121,6 +123,30 @@ void main() {
expect(getManifest["hooks"], isNotNull);
expect(getManifest["subscriptions"], isNotNull);
});

test('deep getManifest Test', () async {
var plugin = Plugin(
dynamic: true,
onInit: (plugin) {
return Future.value({});
});
plugin.registerHook(
name: "rpc_command",
callback: (plugin, request) {
plugin.log(level: "info", message: "hook info");
return Future(() => {"result": "continue"});
});
// Adding an empty request and generating a manifest.
var getManifest = await plugin.getManifest(plugin, {});

expect(getManifest.containsKey('hooks'), true);
expect(getManifest["hooks"], isNotNull);
var hooks = List.from(jsonDecode(jsonEncode(getManifest["hooks"])));
expect(hooks.length, 1);
expect(hooks[0]["name"], "rpc_command");
expect(hooks[0]["before"], isNull);
expect(hooks[0]["after"], isNull);
});
});
group('Init test: ', () {
test('Property test - option registered.', () {
Expand Down

0 comments on commit affa3b5

Please sign in to comment.