BVB Source Codes

mongo-express Show csvSpec.js Source code

Return Download mongo-express: download csvSpec.js Source code - Download mongo-express Source code - Type:.js
  1. 'use strict';
  2.  
  3. var expect = require('chai').expect;
  4. var mongo = require('mongodb');
  5. var csv = require('../../lib/csv');
  6.  
  7. var test = function (data, result) {
  8.   expect(csv(data)).to.eql(result);
  9. };
  10.  
  11. describe('CSV', function () {
  12.   it('should handle nested objects', function () {
  13.     var data = [{ a: { b: 2 } }];
  14.     var result = '"a.b"\n2';
  15.     test(data, result);
  16.   });
  17.  
  18.   it('should handle schema difference between objects', function () {
  19.     var data = [{ b: 2, a: 2 }, { c: 3, a: 4 }];
  20.     var result = '"b","a","c"\n2,2,\n,4,3';
  21.     test(data, result);
  22.   });
  23.  
  24.   it('should handle mongo ObjectID', function () {
  25.     var data = [{ a: { a: mongo.ObjectID('111111111111111111111111') } }];
  26.     var result = '"a.a"\n"ObjectId(""111111111111111111111111"")"';
  27.     test(data, result);
  28.   });
  29.  
  30.   it('should handle simple array', function () {
  31.     var data = [{ a: { b: [1, 2, 3] } }];
  32.     var result = '"a.b"\n"[1,2,3]"';
  33.     test(data, result);
  34.   });
  35.  
  36.   it('should handle complex array', function () {
  37.     var data = [{ a: { b: [{ a: 2 }, 3] } }];
  38.     var result = '"a.b"\n"[{""a"":2},3]"';
  39.     test(data, result);
  40.   });
  41. });
  42.  
downloadcsvSpec.js Source code - Download mongo-express Source code
Related Source Codes/Software:
XCL-Charts - Android charting libraries (XCL-Charts is a free c... 2017-05-17
scrollMonitor - A simple and fast API to monitor elements as you s... 2017-05-16
XCDYouTubeKit - YouTube video player for iOS, tvOS and macOS 2017-05-16
rails-erd - Generate Entity-Relationship Diagrams for Rails ap... 2017-05-16
np - A better `npm publish` 2017-05-16
kaminari - A Scope & Engine based, clean, powerful, custo... 2017-06-04
python-fire - Python Fire is a library for automatically generat... 2017-06-04
Dapper - Dapper - a simple object mapper for .Net 2017-06-05
pkg - Package your Node.js project into an executable ... 2017-06-05
packer - Packer is a tool for creating identical machine im... 2017-06-05
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top