check-ens
v0.1.15
Published
This repository contains various test scripts to verify the functionality of the ENS validator module.
Readme
ENS Validator Module Test Suite
This repository contains various test scripts to verify the functionality of the ENS validator module.
Prerequisites
Before running the tests, make sure you have Node.js installed and install the required dependencies:
npm installAvailable Test Scripts
The following test scripts are available:
1. Basic Test
Runs basic tests without any mocking, which will make actual API calls:
npm test2. Mocked Test
Runs tests with mocked HTTP requests to prevent actual API calls:
npm run test:mock3. Jest Test Suite
Runs comprehensive tests using the Jest testing framework:
npm run test:jestTest Files
test.js- Basic test script that makes actual API callstest-with-mock.js- Tests with mocked HTTP requests using Nockjest-test.js- Jest test suite with more comprehensive mocking and assertions
Important Notes
- The mocked tests will not send any actual requests to external APIs
- The basic test (
test.js) will make actual API calls, which might result in real data being sent - If you're testing in a production environment, always use the mocked tests
Troubleshooting
If you encounter any issues running the tests:
- Make sure all dependencies are installed
- Check that the module path is correct in the test files
- Ensure you have proper network connectivity for the non-mocked tests
This is a very simple npm module.
My Module
A brief description of my module.
Installation
npm install check-ensUsage
JavaScript
const { validateENS } = require('check-ens');
// Example usage with async/await
async function example() {
try {
const result = await validateENS('example.eth');
console.log('Validation result:', result);
} catch (error) {
console.error('Validation error:', error);
}
}
example();TypeScript
The package includes TypeScript declarations:
import { validateENS, ValidationResponse } from 'check-ens';
// Example usage with async/await
async function example() {
try {
const result: ValidationResponse = await validateENS('example.eth');
console.log('Validation result:', result);
// Access typed properties
if (result.success) {
console.log('Message:', result.message);
} else {
console.error('Error:', result.error);
}
} catch (error) {
console.error('Validation error:', error);
}
}
example();API
validateENS(data: string): Promise
Validates an ENS name or processes text data.
Parameters:
data(string): The text or ENS name to validate.
Returns:
- Promise: A promise that resolves to the validation result.
Types
interface ValidationResponse {
success?: boolean;
message?: string;
result?: any;
error?: string;
[key: string]: any; // Additional properties
}