Skip to content

Commit

Permalink
increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
frnandu committed Dec 26, 2024
1 parent 335780c commit f64516c
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions packages/ndk/test/usecases/nwc/nostr_wallet_connect_uri_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:ndk/domain_layer/usecases/nwc/nostr_wallet_connect_uri.dart';
import 'package:test/test.dart';

void main() {
group('NostrWalletConnectUri', () {
test('should parse a valid connection URI', () {
final uri = 'nostr://pubkey123?relay=wss://relay.example.com&secret=secret123&lud16=lud16value';
final nostrUri = NostrWalletConnectUri.parseConnectionUri(uri);

expect(nostrUri.walletPubkey, equals('pubkey123'));
expect(nostrUri.relay, equals('wss://relay.example.com'));
expect(nostrUri.secret, equals('secret123'));
expect(nostrUri.lud16, equals('lud16value'));
});

test('should throw an exception for missing required fields', () {
final uri = 'nostr://pubkey123?relay=wss://relay.example.com';

expect(
() => NostrWalletConnectUri.parseConnectionUri(uri),
throwsA(isA<Exception>()),
);
});

test('should correctly compare two equal instances', () {
final uri1 = NostrWalletConnectUri(
walletPubkey: 'pubkey123',
relay: 'wss://relay.example.com',
secret: 'secret123',
lud16: 'lud16value',
);

final uri2 = NostrWalletConnectUri(
walletPubkey: 'pubkey123',
relay: 'wss://relay.example.com',
secret: 'secret123',
lud16: 'lud16value',
);

expect(uri1, equals(uri2));
});

test('should correctly compare two different instances', () {
final uri1 = NostrWalletConnectUri(
walletPubkey: 'pubkey123',
relay: 'wss://relay.example.com',
secret: 'secret123',
lud16: 'lud16value',
);

final uri2 = NostrWalletConnectUri(
walletPubkey: 'pubkey456',
relay: 'wss://relay.example.com',
secret: 'secret123',
lud16: 'lud16value',
);

expect(uri1, isNot(equals(uri2)));
});
});
}

0 comments on commit f64516c

Please sign in to comment.