@bsv/wallet-toolbox
Version:
BRC100 conforming wallet, wallet storage and wallet signer components
52 lines • 2.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const TestUtilsWalletStorage_1 = require("../../../test/utils/TestUtilsWalletStorage");
const WABClient_1 = require("../WABClient");
const TwilioPhoneInteractor_1 = require("../auth-method-interactors/TwilioPhoneInteractor");
// This test suite requires the WAB server to be running on localhost:3000 or you can
// spin up a test environment or mock server. For demonstration, we'll keep it simple.
describe('WABClient', () => {
let client;
const serverUrl = 'http://localhost:3000'; // Adjust if your server is different
const testPresentationKey = 'clientTestKey' + Date.now();
beforeAll(() => {
client = new WABClient_1.WABClient(serverUrl);
});
it('00', () => { });
// Don't run any of these tests whe
if (TestUtilsWalletStorage_1._tu.noEnv('main'))
return;
it('should get server info', async () => {
const info = await client.getInfo();
expect(info.supportedAuthMethods).toContain('TwilioPhone');
});
it('should do Twilio phone flow', async () => {
const twilio = new TwilioPhoneInteractor_1.TwilioPhoneInteractor();
const startRes = await client.startAuthMethod(twilio, testPresentationKey, {
phoneNumber: '+12223334444'
});
expect(startRes.success).toBe(true);
const completeRes = await client.completeAuthMethod(twilio, testPresentationKey, {
otp: '123456',
phoneNumber: '+12223334444'
});
expect(completeRes.success).toBe(true);
expect(completeRes.presentationKey).toBe(testPresentationKey);
});
it('should request faucet', async () => {
const faucetRes = await client.requestFaucet(testPresentationKey);
expect(faucetRes.success).toBe(true);
expect(faucetRes.paymentData).toBeDefined();
expect(faucetRes.paymentData.amount).toBe(1000);
});
it('should list linked methods', async () => {
const linked = await client.listLinkedMethods(testPresentationKey);
expect(linked.authMethods).toHaveLength(1);
expect(linked.authMethods[0].methodType).toBe('TwilioPhone');
});
it('can delete user', async () => {
const del = await client.deleteUser(testPresentationKey);
expect(del.success).toBe(true);
});
});
//# sourceMappingURL=WABClient.man.test.js.map