92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
/**
|
|
* Tests for main SDK
|
|
*/
|
|
|
|
import { DragonchainSDK } from '../src/index';
|
|
|
|
describe('DragonchainSDK', () => {
|
|
const testConfig = {
|
|
publicId: 'test-public-id',
|
|
authKeyId: 'test-auth-key-id',
|
|
authKey: 'test-auth-key',
|
|
baseURL: 'https://test.dragonchain.com',
|
|
};
|
|
|
|
let sdk: DragonchainSDK;
|
|
|
|
beforeEach(() => {
|
|
sdk = new DragonchainSDK(
|
|
testConfig.publicId,
|
|
testConfig.authKeyId,
|
|
testConfig.authKey,
|
|
testConfig.baseURL
|
|
);
|
|
});
|
|
|
|
describe('initialization', () => {
|
|
it('should create SDK instance', () => {
|
|
expect(sdk).toBeDefined();
|
|
});
|
|
|
|
it('should initialize all client modules', () => {
|
|
expect(sdk.transaction).toBeDefined();
|
|
expect(sdk.transactionType).toBeDefined();
|
|
expect(sdk.contract).toBeDefined();
|
|
expect(sdk.block).toBeDefined();
|
|
expect(sdk.system).toBeDefined();
|
|
});
|
|
|
|
it('should provide access to underlying client', () => {
|
|
const client = sdk.getClient();
|
|
expect(client).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('module methods', () => {
|
|
it('should have transaction module with correct methods', () => {
|
|
expect(typeof sdk.transaction.create).toBe('function');
|
|
expect(typeof sdk.transaction.createBulk).toBe('function');
|
|
expect(typeof sdk.transaction.get).toBe('function');
|
|
expect(typeof sdk.transaction.list).toBe('function');
|
|
});
|
|
|
|
it('should have transactionType module with correct methods', () => {
|
|
expect(typeof sdk.transactionType.create).toBe('function');
|
|
expect(typeof sdk.transactionType.get).toBe('function');
|
|
expect(typeof sdk.transactionType.list).toBe('function');
|
|
expect(typeof sdk.transactionType.delete).toBe('function');
|
|
});
|
|
|
|
it('should have contract module with correct methods', () => {
|
|
expect(typeof sdk.contract.create).toBe('function');
|
|
expect(typeof sdk.contract.get).toBe('function');
|
|
expect(typeof sdk.contract.list).toBe('function');
|
|
expect(typeof sdk.contract.update).toBe('function');
|
|
expect(typeof sdk.contract.upload).toBe('function');
|
|
expect(typeof sdk.contract.delete).toBe('function');
|
|
});
|
|
|
|
it('should have block module with correct methods', () => {
|
|
expect(typeof sdk.block.get).toBe('function');
|
|
});
|
|
|
|
it('should have system module with correct methods', () => {
|
|
expect(typeof sdk.system.health).toBe('function');
|
|
expect(typeof sdk.system.status).toBe('function');
|
|
});
|
|
});
|
|
|
|
describe('timeout configuration', () => {
|
|
it('should accept custom timeout', () => {
|
|
const customSdk = new DragonchainSDK(
|
|
testConfig.publicId,
|
|
testConfig.authKeyId,
|
|
testConfig.authKey,
|
|
testConfig.baseURL,
|
|
60000
|
|
);
|
|
expect(customSdk).toBeDefined();
|
|
});
|
|
});
|
|
});
|