-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
packages/ndk/test/usecases/nwc/nostr_wallet_connect_uri_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
}); | ||
}); | ||
} |