diff --git a/.gitignore b/.gitignore index 1d35e45..a19c591 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ out/ node_modules/ *.tgz npm-debug.log -build/ \ No newline at end of file +build/ +mocha_tests/out \ No newline at end of file diff --git a/.npmignore b/.npmignore index e8e12e8..076b598 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ .idea *.tgz -out \ No newline at end of file +out +mocha_tests \ No newline at end of file diff --git a/__tests__/main-tests.js b/__tests__/main-tests.js index 67482e7..4d99441 100644 --- a/__tests__/main-tests.js +++ b/__tests__/main-tests.js @@ -235,6 +235,8 @@ describe('Client', () => { fs.writeFileSync(archiveFile, 'some file'); mkdirp(archiveDir); + let rc = require('resource-container'); + expect(fileUtils.fileExists(archiveFile)).toBeTruthy(); expect(fileUtils.fileExists(archiveDir)).toBeTruthy(); @@ -251,7 +253,6 @@ describe('Client', () => { ] }; - return client.legacy_tools.downloadFutureCompatibleResourceContainer('en', 'obs', 'obs') .then(() => { expect(request.download.mock.calls.length).toEqual(1); diff --git a/lib/main.js b/lib/main.js index 12899e9..d07a82c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -774,7 +774,7 @@ function Client(dbPath, resourceDir, opts) { if(!containerFormat) throw new Error('Unknown resource format'); containerFormat.imported = 0; resource.formats = [containerFormat]; - library.public_getters.addResource(resource, resource.project_id); + library.addResource(resource, resource.project_id); let data = fs.readFileSync(path, {encoding: 'utf8'}); diff --git a/mocha_tests/download.js b/mocha_tests/download.js new file mode 100644 index 0000000..e9b142c --- /dev/null +++ b/mocha_tests/download.js @@ -0,0 +1,19 @@ +var rimraf = require('rimraf'); +var mkdirp = require('mkdirp'); +var assert = require('assert'); +describe('Download', function() { + let client; + + beforeEach(function() { + rimraf.sync('mocha_tests/out'); + let Door43Client = require('../'); + client = new Door43Client('mocha_tests/index.sqlite', 'mocha_tests/out/containers'); + }); + + describe('download container', function() { + this.timeout(10000); + it('should download a resource container successfully', function() { + return client.downloadResourceContainer('en', 'gen', 'ulb'); + }); + }); +}); \ No newline at end of file diff --git a/mocha_tests/index.sqlite b/mocha_tests/index.sqlite new file mode 100644 index 0000000..b0512fd Binary files /dev/null and b/mocha_tests/index.sqlite differ diff --git a/package.json b/package.json index 3470206..308712d 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "door43-client", - "version": "0.7.7", + "version": "0.8.0", "description": "A client library for interacting with the Door43 Resource API.", "main": "./lib/main.js", "scripts": { - "test": "jest" + "test": "jest; mocha mocha_tests/*.js" }, "repository": { "type": "git", @@ -20,7 +20,7 @@ "gulp": "^3.9.1", "gulp-mocha": "^2.2.0", "jest": "^13.2.3", - "mocha": "^2.4.5", + "mocha": "^2.5.3", "yargs": "^4.8.0" }, "bin": { @@ -35,7 +35,7 @@ "mkdirp": "^0.5.1", "mv": "^2.1.1", "ncp": "^2.0.0", - "resource-container": "^0.10.3", + "resource-container": "^0.11.0", "rimraf": "^2.5.3", "sql.js": "^0.2.21", "tar-fs": "^1.13.0",