mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 02:44:45 +00:00
refactor(packages/stdlib): reformat test files
This commit is contained in:
@@ -2,7 +2,7 @@ import { describe,it, expect } from 'vitest';
|
||||
import { clamp } from '.';
|
||||
|
||||
describe('clamp', () => {
|
||||
it('should clamp a value within the given range', () => {
|
||||
it('clamp a value within the given range', () => {
|
||||
// value < min
|
||||
expect(clamp(-10, 0, 100)).toBe(0);
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('clamp', () => {
|
||||
expect(clamp(50, 100, 100)).toBe(100);
|
||||
});
|
||||
|
||||
it('should handle floating-point numbers correctly', () => {
|
||||
it('handle floating-point numbers correctly', () => {
|
||||
// floating-point value within range
|
||||
expect(clamp(3.14, 0, 5)).toBe(3.14);
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('clamp', () => {
|
||||
expect(clamp(15.75, 0, 10)).toBe(10);
|
||||
});
|
||||
|
||||
it('should handle edge cases', () => {
|
||||
it('handle edge cases', () => {
|
||||
// all values are the same
|
||||
expect(clamp(5, 5, 5)).toBe(5);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
|
||||
import { mapRange } from './index';
|
||||
|
||||
describe('mapRange', () => {
|
||||
it('should map values from one range to another', () => {
|
||||
it('map values from one range to another', () => {
|
||||
// value at midpoint
|
||||
expect(mapRange(5, 0, 10, 0, 100)).toBe(50);
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('mapRange', () => {
|
||||
expect(mapRange(-25, -50, 0, 0, 100)).toBe(50);
|
||||
});
|
||||
|
||||
it('should handle floating-point numbers correctly', () => {
|
||||
it('handle floating-point numbers correctly', () => {
|
||||
// floating-point value
|
||||
expect(mapRange(3.5, 0, 10, 0, 100)).toBe(35);
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('mapRange', () => {
|
||||
expect(mapRange(-1.25, -2.5, 0, 0, 100)).toBe(50);
|
||||
});
|
||||
|
||||
it('should handle edge cases', () => {
|
||||
it('handle edge cases', () => {
|
||||
// input range is zero (should return output min)
|
||||
expect(mapRange(5, 0, 0, 0, 100)).toBe(0);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
|
||||
import {levenshteinDistance} from '.';
|
||||
|
||||
describe('levenshteinDistance', () => {
|
||||
it('should calculate edit distance between two strings', () => {
|
||||
it('calculate edit distance between two strings', () => {
|
||||
// just one substitution I at the beginning
|
||||
expect(levenshteinDistance('islander', 'slander')).toBe(1);
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('levenshteinDistance', () => {
|
||||
expect(levenshteinDistance('intention', 'execution')).toBe(5);
|
||||
});
|
||||
|
||||
it('should handle edge cases', () => {
|
||||
it('handle empty strings', () => {
|
||||
expect(levenshteinDistance('', '')).toBe(0);
|
||||
expect(levenshteinDistance('a', '')).toBe(1);
|
||||
expect(levenshteinDistance('', 'a')).toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user