Skip to content

Commit

Permalink
test: add some test
Browse files Browse the repository at this point in the history
  • Loading branch information
gafreax committed Jan 30, 2024
1 parent c209736 commit 3e7f6ae
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/table.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { maxColumnLen } from "./table.js";

describe('table.js', () => {
describe('maxColumnLen', () => {
test('to be the longest decription field', () => {
const max = maxColumnLen([{description: 'test'},{description: 'test2'}])
expect(max).toBe(5);
})
})
})
21 changes: 21 additions & 0 deletions src/lib/text.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ellipsys } from "./text.js"

describe('text.js', () => {
describe("ellipsys", () => {
test('return truncated first word if len < lenght of the first word', () => {
const phrase = 'Next tick shim that prefers process.nextTick over queueMicrotask for compat'
const truncated = ellipsys(phrase, 3)
expect(truncated).toBe('Nex...')
})
test('ellipsys return original string if its length < len', () => {
const phrase = 'Next'
const notTruncated = ellipsys(phrase, 10)
expect(notTruncated).toBe(phrase)
})
test('ellipsys return truncated string at last space if its lenght > len and len > fisrt space position ', () => {
const phrase = 'Next tick shim that prefers process.nextTick over queueMicrotask for compa'
const truncatedLastSpace = ellipsys(phrase, 17)
expect(truncatedLastSpace).toBe('Next tick shim...')
})
})
})

0 comments on commit 3e7f6ae

Please sign in to comment.