forked from sheetjs/sheetjs
		
	- extraneous '[' does not cause infinite loop - dates follow excel form (`yyyyyy` treated as `yyyy`) - more general exponential form (more tests) - unreachable default cases removed - 100% test coverage - added test_min and cov_min targets
		
			
				
	
	
		
			23 lines
		
	
	
		
			773 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			773 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/* vim: set ts=2: */
 | 
						|
/*jshint loopfunc:true */
 | 
						|
var SSF = require('../');
 | 
						|
var fs = require('fs'), assert = require('assert');
 | 
						|
var data = JSON.parse(fs.readFileSync('./test/oddities.json','utf8'));
 | 
						|
describe('oddities', function() {
 | 
						|
  data.forEach(function(d) {
 | 
						|
    it(d[0], function(){
 | 
						|
      for(j=1;j<d.length;++j) {
 | 
						|
        if(d[j].length == 2) {
 | 
						|
          var expected = d[j][1], actual = SSF.format(d[0], d[j][0], {});
 | 
						|
          assert.equal(actual, expected);
 | 
						|
        } else assert.throws(function() { SSF.format(d[0], d[j][0]); });
 | 
						|
      }
 | 
						|
    });
 | 
						|
  });
 | 
						|
  it('should fail for bad formats', function() {
 | 
						|
    var bad = ['##,##'];
 | 
						|
    var chk = function(fmt){ return function(){ SSF.format(fmt,0); }; };
 | 
						|
    bad.forEach(function(fmt){assert.throws(chk(fmt));});
 | 
						|
  });
 | 
						|
});
 |