File numberFormat.spec.js
has 413 lines of code (exceeds 250 allowed). Consider refactoring.
import formatter from '../numberFormat';
describe('numberFormat', () => {
describe('formatter', () => {
let f;
Similar blocks of code found in 2 locations. Consider refactoring.
it('should support octal formatting', () => {
f = formatter('(oct)');
expect(f(0)).to.equal('0');
expect(f(1)).to.equal('1');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 355..363 Similar blocks of code found in 2 locations. Consider refactoring.
it('should support binary formatting', () => {
f = formatter('(bin)');
expect(f(0)).to.equal('0');
expect(f(1)).to.equal('1');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 345..353 Similar blocks of code found in 2 locations. Consider refactoring.
it('should support roman numerals and ignore decimals', () => {
f = formatter('(ROM)');
expect(f(0.12345)).to.equal('0');
expect(f(1.2345)).to.equal('I');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 365..372 Similar blocks of code found in 2 locations. Consider refactoring.
it('should support arbitrary base/radix', () => {
f = formatter('(r04)');
expect(f(0)).to.equal('0');
expect(f(1)).to.equal('1');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 411..418 Similar blocks of code found in 2 locations. Consider refactoring.
it('should round values correctly when type is "F"', () => {
f = formatter('0', ',', '.', 'F');
expect(f(0.3)).to.equal('0');
expect(f(-0.3)).to.equal('0');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 36..42 Similar blocks of code found in 2 locations. Consider refactoring.
it('should round values correctly when type is "I"', () => {
f = formatter('0', ',', '.', 'I');
expect(f(0.3)).to.equal('0');
expect(f(-0.3)).to.equal('0');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 52..58 Similar blocks of code found in 2 locations. Consider refactoring.
it('numbers >= 1e15 should always be formatted in scientific notation', () => {
f = formatter('#', ',', '.');
expect(f(1.123e15)).to.equal('1e+15');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 195..203 Similar blocks of code found in 2 locations. Consider refactoring.
it('should ignore grouping if grouping separator is same as decimal separator', () => {
f = formatter('#.###.###', '.', '.');
expect(f(123456789.987)).to.equal('123456789.987');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 26..34 Similar blocks of code found in 3 locations. Consider refactoring.
it('should support positive and negative formatting', () => {
f = formatter('0.0;(0.0)');
expect(f(1.234)).to.equal('1.2');
expect(f(-1.234)).to.equal('(1.2)');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 308..313 plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 431..436 Similar blocks of code found in 3 locations. Consider refactoring.
it('should support positive and negative formatting with percentage', () => {
f = formatter('0.0%;(0.0%)');
expect(f(0.1234)).to.equal('12.3%');
expect(f(-0.1234)).to.equal('(12.3%)');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 301..306 plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 431..436 Similar blocks of code found in 3 locations. Consider refactoring.
it('should support roman numerals and return the same format as engine when value > 500000', () => {
f = formatter('(ROM)');
expect(f(500001)).to.equal('(ROM)5e+5');
expect(f(-99999999)).to.equal('(ROM)-1e+8');
plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 301..306 plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 308..313 There are no issues that match your filters.