From 657264d26b4be3a9d0954f5a739550007926cbd2 Mon Sep 17 00:00:00 2001 From: roll Date: Fri, 17 Feb 2017 23:58:40 +0300 Subject: [PATCH] renamed to datapackage --- README.md | 4 +- package.json | 2 +- test/browser/index.html | 4 +- test/browser/jsdomSetup.js | 4 +- test/browser/profiles.js | 99 -------------------------------------- webpack.config.js | 4 +- 6 files changed, 9 insertions(+), 108 deletions(-) delete mode 100644 test/browser/profiles.js diff --git a/README.md b/README.md index 8bb2031..b23c8a5 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ A model for working with [Data Packages]. ```bash -$ npm install datapackage-test +$ npm install datapackage ``` ##Example @@ -95,7 +95,7 @@ new Datapackage('http://bit.do/datapackage-json', 'base', false).then(datapackag - default `basePath` is empty String (`''`) - any explicit `basePath` will be used as `basePath` - In case when the resource path is an absolute URL, `basePath` is disregarded and only the URL is used to fetch the resource. - - Examples + - Examples - `datapackage` is initialized with the `my-datapackages/datapackage.json` descriptor, the `basePath` is set to `data/` and the resource path is `november/resource.csv` the resource is expected to be in `my-datapackages/data/november/resource.cvs` relative of the directory where the library is executed. ###Class methods diff --git a/package.json b/package.json index 96d63a2..59524ae 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "datapackage-test", + "name": "datapackage", "version": "0.2.4", "description": "Utilities to work with Data Packages as defined on dataprotocols.org", "keywords": [ diff --git a/test/browser/index.html b/test/browser/index.html index 18ae615..81c28ce 100644 --- a/test/browser/index.html +++ b/test/browser/index.html @@ -12,9 +12,9 @@ mocha.reporter('html'); var assert = chai.assert; - + - \ No newline at end of file + diff --git a/test/browser/jsdomSetup.js b/test/browser/jsdomSetup.js index a127f18..4e9ae78 100644 --- a/test/browser/jsdomSetup.js +++ b/test/browser/jsdomSetup.js @@ -1,7 +1,7 @@ import jsdom from 'jsdom' import fs from 'fs' -const testBundle = fs.readFileSync('./dist/datapackage-test.js', 'utf8') +const testBundle = fs.readFileSync('./dist/datapackage.js', 'utf8') export default testingClass => { const document = jsdom.jsdom() @@ -11,5 +11,5 @@ export default testingClass => { scriptEl.textContent = testBundle document.body.appendChild(scriptEl) - return window.Datapackage[testingClass] + return window.datapackage[testingClass] } diff --git a/test/browser/profiles.js b/test/browser/profiles.js deleted file mode 100644 index 429762a..0000000 --- a/test/browser/profiles.js +++ /dev/null @@ -1,99 +0,0 @@ -/* eslint-disable */ - -import chai from 'chai' -import _ from 'lodash' -import jsdomSetup from './jsdomSetup' - -const assert = chai.assert - -let Profiles -describe('browser: Profiles', () => { - - beforeEach(() => { - Profiles = jsdomSetup('Profiles') - }) - - describe('#retrieve', () => { - it('returns `null` if profile ID doesn\'t exist', async() => { - const profiles = await new Profiles(true) - const retrieved = profiles.retrieve('inexistent-profile-id') - - assert(retrieved === null, 'Value should be null') - }) - - it('returns remote profile by its ID', async() => { - const profiles = await new Profiles(true) - const baseProfile = require('../../src/schemas/data-package.json') - const retrieved = profiles.retrieve('base') - - assert.deepEqual(retrieved, baseProfile) - }) - - it('returns local profile by its ID', async() => { - const profiles = await new Profiles(false) - const schema = require('../../src/schemas/tabular-data-package.json') - const retrieved = profiles.retrieve('tabular') - - assert.deepEqual(retrieved, schema) - }) - }) - - describe('#validate', () => { - it('throw array of errors if the descriptor is invalid', async() => { - const profiles = await new Profiles(false) - - assert(_.isArray(profiles.validate({}))) - }) - - it('returns true for valid local descriptor', async() => { - const profiles = await new Profiles(false) - const datapackage = require('../../data/dp1/datapackage.json') - - assert(profiles.validate(datapackage) === true) - }) - - it('returns array of lint errors for invalid json string', async() => { - const profiles = await new Profiles(false) - const descriptor = '{"test","resources":[]}' - - assert(_.isArray(profiles.validate(descriptor))) - }) - - it('returns array of Errors for invalid string descriptor', - async() => { - const profiles = await new Profiles(false) - const descriptor = '{"test": "shouldbename","resources":[]}' - - assert(_.isArray(profiles.validate(descriptor))) - }) - - it('returns true for valid data and schema passed as argument', - async() => { - const schema = require('../../src/schemas/tabular-data-package.json') - const descriptor = require('../../data/dp2-tabular/datapackage.json') - const profiles = await new Profiles(false) - - assert(profiles.validate(descriptor, schema) === true) - }) - }) - - describe('#_basePath', () => { - it('returns null if using remote', async() => { - const profiles = await new Profiles(true) - const path = profiles._basePath - - assert(path === null) - }) - }) - - describe('README', () => { - it('#Example 1', done => { - new Profiles(true).then(profiles => { - assert(typeof profiles.retrieve('fiscal') === 'object') - done() - }).catch(err => { - done(err) - }) - }) - }) -}) diff --git a/webpack.config.js b/webpack.config.js index 86ac5ea..8e6b32d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,7 +16,7 @@ let webpackConfig = { { test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ } ] }, - output: { library: 'Datapackage', libraryTarget: 'umd' }, + output: { library: 'datapackage', libraryTarget: 'umd' }, node: { fs: 'empty' } @@ -68,7 +68,7 @@ if (ENV === 'test') { webpackConfig = merge(webpackConfig, { entry: './test/browser/buildIndex.js', output: { - filename: 'datapackage-test.js', + filename: 'datapackage.js', path: './dist' }, plugins: [