Skip to content

Commit a7e5087

Browse files
committed
[datajs][lg]: move src code outside datajs folder
1 parent f2571e2 commit a7e5087

40 files changed

+47
-117
lines changed

datajs/browser-test/index.spec.js

-70
This file was deleted.

karma.conf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ module.exports = function (config) {
1111
frameworks: ['jasmine', 'browserify'],
1212

1313
// list of files / patterns to load in the browser
14-
files: ['dist/browser/bundle.js', 'datajs/browser-test/*.js'],
14+
files: ['dist/browser/bundle.js', 'browser-test/*.js'],
1515

1616
// list of files / patterns to exclude
1717
exclude: [],
1818

1919
// preprocess matching files before serving them to the browser
2020
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
2121
preprocessors: {
22-
'datajs/browser-test/*.js': ['browserify'],
22+
'browser-test/*.js': ['browserify'],
2323
},
2424

2525
// test results reporter to use

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
"description": "",
55
"main": "dist/node/index.js",
66
"directories": {
7-
"test": "datajs/test"
7+
"test": "src/test"
88
},
99
"scripts": {
1010
"test": "yarn run test:node && yarn run test:browser",
1111
"test:browser": "yarn run build:browser && karma start karma.conf.js --browsers=ChromeHeadless",
12-
"test:node": "nyc mocha --require @babel/register datajs/test/*",
12+
"test:node": "nyc mocha --require @babel/register test/*",
1313
"build:browser": "webpack --mode production",
14-
"build:node": "babel ./datajs/ -d ./dist/node --no-comments",
14+
"build:node": "babel ./src/ -d ./dist/node --no-comments",
1515
"build": "yarn run build:node && yarn run build:browser",
1616
"build:watch": "webpack --watch",
1717
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
1818
"coverage": "nyc report --reporter=text-lcov | coveralls && nyc report --reporter=lcov",
19-
"lint": "eslint ./datajs"
19+
"lint": "eslint ./src"
2020
},
2121
"repository": {
2222
"type": "git",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

datajs/test/data.js renamed to test/data.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'assert'
22
import path from 'path'
33
import nock from 'nock'
4-
import * as data from '../data'
4+
import * as data from '../src/data'
55

66
describe('isUrl', () => {
77
it('Tests if given path is url or not', async () => {
@@ -160,15 +160,15 @@ describe('parsePath', () => {
160160

161161
describe('isDataset', () => {
162162
it('isDataset function works on different examples', async () => {
163-
let pathToDataset = 'datajs/test/fixtures/co2-ppm'
163+
let pathToDataset = 'test/fixtures/co2-ppm'
164164
let res = data.isDataset(pathToDataset)
165165
assert.strictEqual(res, true)
166166

167-
pathToDataset = 'datajs/test/fixtures/co2-ppm/datapackage.json'
167+
pathToDataset = 'test/fixtures/co2-ppm/datapackage.json'
168168
res = data.isDataset(pathToDataset)
169169
assert.strictEqual(res, true)
170170

171-
const pathToFile = 'datajs/test/fixtures/sample.csv'
171+
const pathToFile = 'test/fixtures/sample.csv'
172172
res = data.isDataset(pathToFile)
173173
assert.strictEqual(res, false)
174174

datajs/test/dataset.js renamed to test/dataset.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import assert from 'assert'
22
import path from 'path'
33
import nock from 'nock'
4-
import * as data from '../data'
5-
import { Dataset } from '../dataset'
4+
import * as data from '../src/data'
5+
import { Dataset } from '../src/dataset'
66

77
describe('Dataset', () => {
88
it('Dataset constructor works', async () => {
@@ -18,14 +18,14 @@ describe('Dataset', () => {
1818
})
1919

2020
it('Dataset with inline README works', async () => {
21-
const path = 'datajs/test/fixtures/dp-with-inline-readme'
21+
const path = 'test/fixtures/dp-with-inline-readme'
2222
const dataset = await Dataset.load(path)
2323
assert.deepStrictEqual(dataset.identifier.type, 'local')
2424
assert.deepStrictEqual(dataset.readme, 'This is the README')
2525
})
2626

2727
it('Dataset.load works with co2-ppm', async () => {
28-
const path = 'datajs/test/fixtures/co2-ppm'
28+
const path = 'test/fixtures/co2-ppm'
2929
const dataset2 = await Dataset.load(path)
3030
assert.strictEqual(dataset2.identifier.type, 'local')
3131

@@ -34,7 +34,7 @@ describe('Dataset', () => {
3434
assert.strictEqual(dataset2.resources[0].descriptor.name, 'co2-mm-mlo')
3535
assert.strictEqual(
3636
dataset2.resources[0].path.includes(
37-
'datajs/test/fixtures/co2-ppm/data/co2-mm-mlo.csv'
37+
'test/fixtures/co2-ppm/data/co2-mm-mlo.csv'
3838
),
3939
true
4040
)
@@ -47,7 +47,7 @@ describe('Dataset', () => {
4747
})
4848

4949
it('Dataset.load with dir/datapckage.json', async () => {
50-
const path = 'datajs/test/fixtures/co2-ppm/datapackage.json'
50+
const path = 'test/fixtures/co2-ppm/datapackage.json'
5151
const dataset = await Dataset.load(path)
5252
assert.strictEqual(dataset.descriptor.name, 'co2-ppm')
5353
assert.strictEqual(dataset.identifier.type, 'local')
@@ -91,7 +91,7 @@ describe('Dataset', () => {
9191
it('Dataset.addResource method works', async () => {
9292
const resourceAsPlainObj = {
9393
name: 'sample',
94-
path: 'datajs/test/fixtures/sample.csv',
94+
path: 'test/fixtures/sample.csv',
9595
format: 'csv',
9696
}
9797
const resourceAsFileObj = data.open(resourceAsPlainObj)

datajs/test/file-base.js renamed to test/file-base.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import assert from 'assert'
2-
import * as data from '../data'
2+
import * as data from '../src/data'
33
import toArray from 'stream-to-array'
4-
import { File } from '../file-base'
4+
import { File } from '../src/file-base'
55
// common method to test all the functionality which we can use for all types
66
// of files
77
export const testFile = async (assert, file) => {
8-
assert.strictEqual(file.path, 'datajs/test/fixtures/sample.csv')
8+
assert.strictEqual(file.path, 'test/fixtures/sample.csv')
99
assert.strictEqual(file.size, 46)
1010
await testFileStream(assert, file)
1111
}
@@ -47,7 +47,7 @@ export const testFileStream = async (assert, file) => {
4747

4848
describe('File Base', async () => {
4949
it('cyrillic encoding is working', () => {
50-
const path_ = 'datajs/test/fixtures/sample-cyrillic-encoding.csv'
50+
const path_ = 'test/fixtures/sample-cyrillic-encoding.csv'
5151
const file = data.open(path_)
5252
//const buffer = await file.buffer
5353
//t.is(buffer.toString().slice(0, 12), 'номер, город')
@@ -56,32 +56,32 @@ describe('File Base', async () => {
5656

5757
it('File class with path', async () => {
5858
// With path
59-
const path_ = 'datajs/test/fixtures/sample.csv'
59+
const path_ = 'test/fixtures/sample.csv'
6060
const res = data.open(path_)
6161
await testFile(assert, res)
6262
})
6363

6464
it('File class with descriptor', async () => {
65-
const descriptor = { path: 'datajs/test/fixtures/sample.csv' }
65+
const descriptor = { path: 'test/fixtures/sample.csv' }
6666
const obj2 = data.open(descriptor)
6767
await testFile(assert, obj2)
6868
})
6969

7070
it('File with path and basePath', async () => {
71-
const obj3 = data.open('sample.csv', { basePath: 'datajs/test/fixtures' })
71+
const obj3 = data.open('sample.csv', { basePath: 'test/fixtures' })
7272
testFile(assert, obj3)
7373
})
7474

7575
it('File name has spaces and dots', async () => {
76-
let path_ = 'datajs/test/fixtures/some file.name.ext'
76+
let path_ = 'test/fixtures/some file.name.ext'
7777
let file = File.load(path_)
7878
assert.strictEqual(file.descriptor.name, 'some-file.name')
7979
})
8080
})
8181

8282
describe('bufferInChunks', () => {
8383
it('File is loaded in chunks', async () => {
84-
const path_ = 'datajs/test/fixtures/sample-cyrillic-encoding.csv'
84+
const path_ = 'test/fixtures/sample-cyrillic-encoding.csv'
8585
const file = data.open(path_)
8686

8787
file.bufferInChunks((chunk, percent) => {
@@ -93,7 +93,7 @@ describe('bufferInChunks', () => {
9393

9494
describe('hashSha256', () => {
9595
it('hashSha256 returns right hash', async () => {
96-
const path_ = 'datajs/test/fixtures/sample-cyrillic-encoding.csv'
96+
const path_ = 'test/fixtures/sample-cyrillic-encoding.csv'
9797
const file = data.open(path_)
9898

9999
let hash = await file.hashSha256()

datajs/test/file-inline.js renamed to test/file-inline.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from 'assert'
2-
import * as data from '../data'
2+
import * as data from '../src/data'
33
import toArray from 'stream-to-array'
44
import { testFile } from './file-base'
55

@@ -20,7 +20,7 @@ describe('File-Inline', () => {
2020
const inlineData = `number,string,boolean\n1,two,true\n3,four,false`
2121
// To make it testable with testFile we add the path but it is not needed
2222
const file = data.open({
23-
path: 'datajs/test/fixtures/sample.csv',
23+
path: 'test/fixtures/sample.csv',
2424
format: 'csv',
2525
inlineData,
2626
})

datajs/test/file-local.js renamed to test/file-local.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import assert from 'assert'
2-
import * as data from '../data'
2+
import * as data from '../src/data'
33

44
describe('File Local', function () {
55
it('File class for addSchema method', async () => {
6-
let path_ = 'datajs/test/fixtures/sample.csv'
6+
let path_ = 'test/fixtures/sample.csv'
77
let file = data.open(path_)
88
assert.strictEqual(file.descriptor.schema, undefined)
99

@@ -15,18 +15,18 @@ describe('File Local', function () {
1515
})
1616

1717
it("File classes have displayName method'", () => {
18-
const fileLocal = data.open('datajs/test/fixtures/sample.csv')
18+
const fileLocal = data.open('test/fixtures/sample.csv')
1919
assert.strictEqual(fileLocal.displayName, 'FileLocal')
2020
})
2121

2222
it('Calculates the streaming hash (md5) of a csv file', async () => {
23-
const fileLocal = data.open('datajs/test/fixtures/sample.csv')
23+
const fileLocal = data.open('test/fixtures/sample.csv')
2424
let hash = await fileLocal.hash('md5')
2525
assert.strictEqual(hash, 'b0661d9566498a800fbf95365ce28747')
2626
})
2727

2828
it('Calculates the streaming hash (sha256) of a csv file', async () => {
29-
const fileLocal = data.open('datajs/test/fixtures/sample.csv')
29+
const fileLocal = data.open('test/fixtures/sample.csv')
3030
let hash = await fileLocal.hash('sha256')
3131
assert.strictEqual( hash,'d9d47b90ac9607c5111ff9a83aa37bc10e058ce6206c00b6626ade091784e098')
3232
})

datajs/test/file-remote.js renamed to test/file-remote.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'assert'
22
import path from 'path'
33
import nock from 'nock'
4-
import * as data from '../data'
4+
import * as data from '../src/data'
55
import { testFileStream } from './file-base'
66

77
describe('File Remote', function () {
File renamed without changes.
File renamed without changes.
File renamed without changes.

datajs/test/parser/csv.js renamed to test/parser/csv.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import assert from 'assert'
22
import toArray from 'stream-to-array'
3-
import { csvParser, guessParseOptions } from '../../parser/csv'
4-
import * as data from '../../index'
3+
import { csvParser, guessParseOptions } from '../../src/parser/csv'
4+
import * as data from '../../src/index'
55

66
describe('csvParser', function () {
77
this.timeout(30000) // all tests in this suite get 10 seconds before timeout
88

99
it('csvParser iso8859 file encoding', async () => {
10-
const path_ = 'datajs/test/fixtures/encodings/iso8859.csv'
10+
const path_ = 'test/fixtures/encodings/iso8859.csv'
1111
const file = data.open(path_)
1212
const parsed_file = await csvParser(file)
1313
const rows = await toArray(parsed_file)
@@ -24,7 +24,7 @@ describe('csvParser', function () {
2424
})
2525

2626
it('csvParser western-macos-roman file encoding', async () => {
27-
const path_ = 'datajs/test/fixtures/encodings/western-macos-roman.csv'
27+
const path_ = 'test/fixtures/encodings/western-macos-roman.csv'
2828
const file = data.open(path_)
2929
const parsed_file = await csvParser(file)
3030
const rows = await toArray(parsed_file)
@@ -41,7 +41,7 @@ describe('csvParser', function () {
4141
})
4242

4343
it('guessParseOptions for local data', async () => {
44-
const path_ = 'datajs/test/fixtures/semicolon-delimited.csv'
44+
const path_ = 'test/fixtures/semicolon-delimited.csv'
4545
let file = data.open(path_)
4646
let parseOptions = await guessParseOptions(file)
4747
assert.deepStrictEqual(parseOptions.delimiter, ';')

0 commit comments

Comments
 (0)