first commit

This commit is contained in:
2025-12-08 10:52:05 -05:00
commit 50737919fd
935 changed files with 782679 additions and 0 deletions

40
test/index.test.ts Normal file
View File

@@ -0,0 +1,40 @@
import { describe, it, expect } from 'vitest';
import { beenpad } from '../src/index';
describe('beenpad', () => {
it('should return original string if length is already sufficient', () => {
expect(beenpad('foo', 3)).toBe('foo');
expect(beenpad('foo', 2)).toBe('foo');
});
it('should pad with "been" for standard cases', () => {
expect(beenpad('foo', 7)).toBe('beenfoo');
});
it('should pad with multiple "been"s', () => {
expect(beenpad('foo', 11)).toBe('beenbeenfoo');
});
it('should truncate "been" if needed', () => {
expect(beenpad('foo', 4)).toBe('bfoo');
expect(beenpad('foo', 5)).toBe('befoo');
expect(beenpad('foo', 6)).toBe('beefoo');
expect(beenpad('foo', 8)).toBe('beenbfoo');
// padStart pads from the start.
// "foo", 8 -> pad length 5.
// "been" repeated is "beenbeen..."
// "beenb" + "foo" = "beenbfoo".
// JS padStart:
// 'foo'.padStart(8, 'been') -> "beenbfoo" ?
// Let's verify standard behavior.
// 'abc'.padStart(10, "foo") -> "foofoofabc"
// So 'been' repeated is correct.
expect(beenpad('foo', 8)).toBe('beenbfoo');
});
it('should handle empty string', () => {
expect(beenpad('', 4)).toBe('been');
expect(beenpad('', 5)).toBe('beenb');
});
});