Files
freeCodeCamp/utils/get-lines.test.ts
Tom Fattah 03fbf03c91 refactor(tools/scripts): convert validate and get-lines to TS (#48622)
* fix(tools/scripts) convert validate and get-lines to typescript files

* fix(tools/scripts) refactor validate and get-lines to typescript

* remove any type and eslint ignore

* Update utils/validate.ts

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* address comments

* update .ignore files to ignore newly generated utils files

* Update utils/get-lines.ts

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>

* remove unneeded ErrorInterface

* add local type annotation to 'expected' variable

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
2023-01-08 21:55:06 +00:00

34 lines
1.1 KiB
TypeScript

import { getLines } from './get-lines';
const content = 'one\ntwo\nthree';
describe('dasherize', () => {
it('returns a string', () => {
expect(getLines('')).toBe('');
});
it("returns '' when the second arg is empty", () => {
expect(getLines(content)).toBe('');
});
it("returns '' when the range is negative", () => {
expect(getLines(content, [1, -1])).toBe('');
});
it("returns '' when the range is [n,n]", () => {
expect(getLines(content, [0, 0])).toBe('');
expect(getLines(content, [1, 1])).toBe('');
expect(getLines(content, [2, 2])).toBe('');
});
it('returns the first line when the range is [0,2]', () => {
expect(getLines(content, [0, 2])).toBe('one');
});
it('returns the second line when the range is [1,3]', () => {
expect(getLines(content, [1, 3])).toBe('two');
});
it('returns the first and second lines when the range is [0,3]', () => {
expect(getLines(content, [0, 3])).toBe('one\ntwo');
});
it('returns the second and third lines when the range is [1,4]', () => {
expect(getLines(content, [1, 4])).toBe('two\nthree');
});
});