@ln-markets/sdk
Version:
TypeScript SDK for LNMarkets API v2
30 lines • 958 B
JavaScript
import { beforeEach, describe, expect, test } from 'vitest';
import { createRestClient } from './rest.js';
const getEnvOrThrow = (key) => {
const value = process.env[key];
if (!value) {
throw new Error(`Environment variable ${key} is not set`);
}
return value;
};
beforeEach((ctx) => {
ctx.authClient = createRestClient({
key: getEnvOrThrow('LNM_API_KEY'),
passphrase: getEnvOrThrow('LNM_API_PASSPHRASE'),
secret: getEnvOrThrow('LNM_API_SECRET'),
});
ctx.client = createRestClient({
key: '',
passphrase: '',
secret: '',
});
});
describe('get user route', () => {
test('should throw if not authenticated', async (ctx) => {
await expect(ctx.client.user.get()).rejects.toThrow();
});
test('should return the user', async (ctx) => {
await expect(ctx.authClient.user.get()).resolves.toBeDefined();
});
});
//# sourceMappingURL=rest.test.js.map