feat: Added docs.

This commit is contained in:
Spencer Brower
2023-05-25 15:40:04 -04:00
parent 840a73a4e3
commit 0f0f9b6d5a
8 changed files with 268 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest';
import fc from 'fast-check';
import {
/*afterFirstWord, beforeFirstWord, endsWith,*/ ltrim, startsWith,
/*afterFirstWord, beforeFirstWord, */ endsWith, ltrim, startsWith,
} from './index';
describe('strings', () => {
@@ -20,6 +20,21 @@ describe('strings', () => {
}));
})
});
describe('endsWith', () => {
it('returns true if haystack end with needle', () => {
expect(endsWith('bar', 'foobar')).toBe(true);
})
it('returns true when haystack is needle', () => {
expect(endsWith('foo', 'foo')).toBe(true);
})
it('works', () => {
fc.assert(fc.property(fc.string(), fc.string(), (needle, haystack) => {
if (haystack.substring(haystack.indexOf(needle)) == needle) {
expect(endsWith(needle, haystack)).toBe(true);
}
}));
})
});
// describe('afterFirstWord', () => {
// it('removes the first word', () => {
// fc.assert(fc.property(fc.string(), (str) => {