index.test.js 437 Bytes
Newer Older
sin's avatar
sin committed
1 2 3 4 5 6 7 8 9 10 11 12 13
import { getStrFullLength, cutStrByFullLength } from './index';

describe('test calculateShowLength', () => {
  it('get full length', () => {
    expect(getStrFullLength('一二,a,')).toEqual(8);
  });
  it('cut str by full length', () => {
    expect(cutStrByFullLength('一二,a,', 7)).toEqual('一二,a');
  });
  it('cut str when length small', () => {
    expect(cutStrByFullLength('一22三', 5)).toEqual('一22');
  });
});