UNPKG

1.29 kBJavaScriptView Raw
1"use strict";
2
3var loaders = require('../src/loaders.js')
4, chai = require('chai')
5, chaiAsPromised = require('chai-as-promised');
6
7chai.Should();
8chai.use(chaiAsPromised);
9require("mocha-as-promised")();
10
11describe('loaders', function() {
12
13 describe('#getTsvLoader()', function() {
14
15 var tsvLoader = loaders.getTsvLoader();
16
17 describe('#lineContinues()', function() {
18 it('should determine that the line should continue', function() {
19 tsvLoader.lineContinues('"').should.be.true;
20 tsvLoader.lineContinues('\t"').should.be.true;
21 tsvLoader.lineContinues('test\t"').should.be.true;
22 tsvLoader.lineContinues('"test"').should.be.false;
23 tsvLoader.lineContinues('"middle"middle"').should.be.false;
24 });
25 });
26
27 describe('#lineEnds()', function() {
28 it('should determine that the line should end', function() {
29 tsvLoader.lineEnds('"').should.be.true;
30 tsvLoader.lineEnds('something"').should.be.true;
31 });
32 });
33
34 describe('#toDataRow()', function() {
35 it('should convert a tsv string into a 1D array', function() {
36 var tsvLoader = loaders.getTsvLoader();
37 tsvLoader.toDataRow("test").should.eql(['test']);
38 tsvLoader.toDataRow("test\tstring").should.eql(['test', 'string']);
39 tsvLoader.toDataRow("\t").should.eql(['', '']);
40 });
41 });
42
43 });
44});