Skip to content

Commit

Permalink
Remove unreachable string assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nam Hoang Le committed Apr 24, 2021
1 parent 1b56b29 commit 2bc12b2
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 23 deletions.
4 changes: 0 additions & 4 deletions src/alignString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ const alignCenter = (subject: string, width: number): string => {
* text in a desired alignment within a container.
*/
export default (subject: string, containerWidth: number, alignment: ColumnUserConfig['alignment']): string => {
if (typeof subject !== 'string') {
throw new TypeError('Subject parameter value must be a string.');
}

const subjectWidth = stringWidth(subject);

if (subjectWidth > containerWidth) {
Expand Down
4 changes: 0 additions & 4 deletions src/calculateCellHeight.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import wrapCell from './wrapCell';

export default (value: string, columnWidth: number, useWrapWord = false): number => {
if (typeof value !== 'string') {
throw new TypeError('Value must be a string.');
}

return wrapCell(value, columnWidth, useWrapWord).length;
};
8 changes: 0 additions & 8 deletions test/alignString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ import chalk from 'chalk';
import alignString from '../src/alignString';

describe('alignString', () => {
context('subject parameter value is not a string', () => {
it('throws an error', () => {
expect(() => {
alignString(2 as never, 1, 'left');
}).to.throw(Error, 'Subject parameter value must be a string.');
});
});

context('subject parameter value width is greater than the container width', () => {
it('throws an error', () => {
expect(() => {
Expand Down
7 changes: 0 additions & 7 deletions test/calculateCellHeight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ import calculateCellHeight from '../src/calculateCellHeight';

describe('calculateCellHeight', () => {
describe('value', () => {
context('is not a string', () => {
it('throws an error', () => {
expect(() => {
calculateCellHeight(null as never, 10);
}).to.throw(Error, 'Value must be a string.');
});
});
it('contains newlines', () => {
expect(calculateCellHeight('a\nb\nc', 10)).to.equal(3);
});
Expand Down

0 comments on commit 2bc12b2

Please sign in to comment.