Skip to content

Commit

Permalink
test: cover util tests in describe func
Browse files Browse the repository at this point in the history
  • Loading branch information
koremp committed Sep 2, 2024
1 parent 75a2fec commit 66e2e84
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/__tests__/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
import { get, equal, zeroPad } from '../utils';

test('get', () => {
const state = {
name: '홍길동',
};
describe('utils', () => {
test('get', () => {
const state = {
name: '홍길동',
};

const f = get('name');
const g = get('age');
const f = get('name');
const g = get('age');

expect(f(state)).toBe('홍길동');
expect(g(state)).toBeUndefined();
});
expect(f(state)).toBe('홍길동');
expect(g(state)).toBeUndefined();
});

test('equal', () => {
const state = {
name: '홍길동',
};
test('equal', () => {
const state = {
name: '홍길동',
};

const f = equal('name', '홍길동');
const g = equal('name', '임꺽정');
const f = equal('name', '홍길동');
const g = equal('name', '임꺽정');

expect(f(state)).toBeTruthy();
expect(g(state)).toBeFalsy();
});
expect(f(state)).toBeTruthy();
expect(g(state)).toBeFalsy();
});

test('zeroPad', () => {
const number = 3;
const base = 10;
test('zeroPad', () => {
const number = 3;
const base = 10;

const result = zeroPad(number, base);
const result = zeroPad(number, base);

expect(result).toEqual('03');
expect(result).toEqual('03');
});
});

0 comments on commit 66e2e84

Please sign in to comment.