Skip to content

Commit

Permalink
Merge pull request #22 from rsuite/fix-TablePagination
Browse files Browse the repository at this point in the history
Bugfix: return value mismatch when parameter is 0
  • Loading branch information
simonguo committed May 7, 2018
2 parents 4d5acc3 + 0270f3a commit be13d8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utils/tplTransform.js
Expand Up @@ -2,7 +2,7 @@

import * as React from 'react';

const toJSX = (node, key) => (node ? <span key={key}>{node}</span> : null);
const toJSX = (node, key) => (typeof node !== 'undefined' ? <span key={key}>{node}</span> : null);

/**
* tplTransform('Show {0} data', <i>100</i>);
Expand Down
8 changes: 7 additions & 1 deletion test/utilsSpec.js
Expand Up @@ -9,9 +9,15 @@ describe('[utils] tplTransform', () => {
const str = '{1}Show {0} data {1}, {0}';
const nodes = tplTransform(str, 30, 10);
const instance = ReactTestUtils.renderIntoDocument(<div>{nodes}</div>);

assert.equal(instance.innerText, '10Show 30 data 10, 30');
});

it('Should return match value when parameter is 0', () => {
const str = '共 {0} 条数据';
const nodes = tplTransform(str, 0);
const instance = ReactTestUtils.renderIntoDocument(<div>{nodes}</div>);
assert.equal(instance.innerText, '共 0 条数据');
});
});

describe('[utils] isOneOf', () => {
Expand Down

0 comments on commit be13d8e

Please sign in to comment.