Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit e0b16a4

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
feat(jest): add few more Formatter unit tests
1 parent e2c7ba5 commit e0b16a4

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Column } from '../models';
2+
import { checkboxFormatter } from './checkboxFormatter';
3+
4+
describe('the Checkbox Formatter', () => {
5+
it('should return an empty string when no value is passed', () => {
6+
const value = null;
7+
const result = checkboxFormatter(0, 0, value, {} as Column, {});
8+
expect(result).toBe('');
9+
});
10+
11+
it('should return an empty string when False is provided', () => {
12+
const value = false;
13+
const result = checkboxFormatter(0, 0, value, {} as Column, {});
14+
expect(result).toBe('');
15+
});
16+
17+
it('should return the unicode value of a checkbox when input is True', () => {
18+
const value = true;
19+
const result = checkboxFormatter(0, 0, value, {} as Column, {});
20+
expect(result).toBe('☑');
21+
});
22+
23+
it('should return the unicode value of a checkbox when input is filled with any string', () => {
24+
const value = 'anything';
25+
const result = checkboxFormatter(0, 0, value, {} as Column, {});
26+
expect(result).toBe('☑');
27+
});
28+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Column } from '../models';
2+
import { checkmarkFormatter } from './checkmarkFormatter';
3+
4+
describe('the Checkmark Formatter', () => {
5+
it('should return an empty string when no value is passed', () => {
6+
const value = null;
7+
const result = checkmarkFormatter(0, 0, value, {} as Column, {});
8+
expect(result).toBe('');
9+
});
10+
11+
it('should return an empty string when False is provided', () => {
12+
const value = false;
13+
const result = checkmarkFormatter(0, 0, value, {} as Column, {});
14+
expect(result).toBe('');
15+
});
16+
17+
it('should return the Font Awesome Checkmark icon when input is True', () => {
18+
const value = true;
19+
const result = checkmarkFormatter(0, 0, value, {} as Column, {});
20+
expect(result).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
21+
});
22+
23+
it('should return the Font Awesome Checkmark icon when input is filled with any string', () => {
24+
const value = 'anything';
25+
const result = checkmarkFormatter(0, 0, value, {} as Column, {});
26+
expect(result).toBe('<i class="fa fa-check checkmark-icon" aria-hidden="true"></i>');
27+
});
28+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Column } from '../models';
2+
import { deleteIconFormatter } from './deleteIconFormatter';
3+
4+
describe('the Delete Icon Formatter', () => {
5+
it('should always return the Font Awesome Trash icon even when False is provided', () => {
6+
const value = false;
7+
const result = deleteIconFormatter(0, 0, value, {} as Column, {});
8+
expect(result).toBe('<i class="fa fa-trash pointer delete-icon" aria-hidden="true"></i>');
9+
});
10+
it('should return the Font Awesome Trash icon when input is filled with any string', () => {
11+
const value = 'anything';
12+
const result = deleteIconFormatter(0, 0, value, {} as Column, {});
13+
expect(result).toBe('<i class="fa fa-trash pointer delete-icon" aria-hidden="true"></i>');
14+
});
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Column } from '../models';
2+
import { editIconFormatter } from './editIconFormatter';
3+
4+
describe('the Edit Icon Formatter', () => {
5+
it('should always return the Font Awesome Pencil icon even when False is provided', () => {
6+
const value = false;
7+
const result = editIconFormatter(0, 0, value, {} as Column, {});
8+
expect(result).toBe('<i class="fa fa-pencil pointer edit-icon" aria-hidden="true"></i>');
9+
});
10+
it('should return the Font Awesome Pencil icon when input is filled with any string', () => {
11+
const value = 'anything';
12+
const result = editIconFormatter(0, 0, value, {} as Column, {});
13+
expect(result).toBe('<i class="fa fa-pencil pointer edit-icon" aria-hidden="true"></i>');
14+
});
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Column } from '../models';
2+
import { infoIconFormatter } from './infoIconFormatter';
3+
4+
describe('the Info Icon Formatter', () => {
5+
it('should always return the Font Awesome Info icon even when False is provided', () => {
6+
const value = false;
7+
const result = infoIconFormatter(0, 0, value, {} as Column, {});
8+
expect(result).toBe('<i class="fa fa-info-circle pointer info-icon" aria-hidden="true"></i>');
9+
});
10+
it('should return the Font Awesome Info icon when input is filled with any string', () => {
11+
const value = 'anything';
12+
const result = infoIconFormatter(0, 0, value, {} as Column, {});
13+
expect(result).toBe('<i class="fa fa-info-circle pointer info-icon" aria-hidden="true"></i>');
14+
});
15+
});

0 commit comments

Comments
 (0)