Commit 3e070acc authored by Guillaume Royer's avatar Guillaume Royer

feat(node): run tests with qunit

parent 43030169
......@@ -7,3 +7,5 @@
node_modules/*
lint
package-lock.json
dist/jio*
!dist/jio-node*
examples/
external/
src/
test/
.htaccess
config.mk
Makefile
......@@ -141,19 +141,23 @@ ${JIOVERSION}: ${EXTERNALDIR}/URI.js \
node: ${JIONODELATEST}
${JIONODELATEST}: ${SRCDIR}/node/jio-start.js \
${EXTERNALDIR}/rsvp-2.0.4.js \
${EXTERNALDIR}/moment.js \
${SRCDIR}/node/jio-external.js \
${SRCDIR}/node/jio-compat.js \
${SRCDIR}/queries/parser-begin.js \
${SRCDIR}/queries/build/parser.js \
${SRCDIR}/queries/parser-end.js \
${SRCDIR}/queries/query.js \
${SRCDIR}/node/query.js \
${SRCDIR}/jio.date/jiodate.js \
${SRCDIR}/node/date.js \
${SRCDIR}/jio.js \
${SRCDIR}/node/jio.js \
${SRCDIR}/jio.storage/uuidstorage.js \
${SRCDIR}/jio.storage/documentstorage.js \
${SRCDIR}/jio.storage/erp5storage.js \
${SRCDIR}/jio.storage/memorystorage.js \
${SRCDIR}/jio.storage/querystorage.js \
${SRCDIR}/jio.storage/replicatestorage.js \
${SRCDIR}/jio.storage/uuidstorage.js \
${SRCDIR}/node/jio-end.js
@mkdir -p $(@D)
cat $^ > $@
......
......@@ -19,3 +19,13 @@ RenderJS source code is hosted on Gitlab at [https://lab.nexedi.com/nexedi/jio](
### jIO Test
You can run tests after installing and building jIO by opening the */test/* folder
### Node
1. Run `$ npm install https://lab.nexedi.com/nexedi/jio.git`
2. Import the library:
```
const { jIO } = require('jio');
jIO.createJIO({});
...
```
......@@ -2,7 +2,7 @@
(function (require) {
"use strict";
var jIO = require('../dist/jio-node-latest.js'),
var jIO = require('../dist/jio-node-latest.js').jIO,
storage = jIO.createJIO({type: 'memory'});
storage
.put('1', {
......
{
"name": "jio",
"version": "v3.31.0",
"license": "LGPLv3",
"author": "Nexedi SA",
"contributors": [
"Tristan Cavelier <tristan.cavelier@tiolive.com>",
"Sven Franck <sven.franck@nexedi.com>"
],
"description": "Client-side JavaScript library to manage documents across multiple storages",
"main": "dist/jio-node-latest.js",
"directories": {
"example": "examples",
"test": "test"
},
"scripts": {
"build": "make node",
"test": "node test/node.js"
},
"repository": {
"type": "git",
"url": "https://lab.nexedi.com/nexedi/jio.git"
},
"keywords": [
"io",
"input",
"output",
"cloud"
],
"dependencies": {
"form-data": "^2.3.2",
"moment": "2.21.0",
"rsvp": "git+https://lab.nexedi.com/nexedi/rsvp.js.git",
"rusha": "0.8.2",
"urijs": "^1.19.1",
"uritemplate": "git+https://lab.nexedi.com/nexedi/uritemplate-js.git",
"xhr2": "^0.1.4"
},
"devDependencies": {
"qunit": "git://github.com/qunitjs/node-qunit.git#v0.9.3",
"sinon": "~1.7.3"
},
"engines": {
"npm": ">=1.3"
}
}
var jiodate = window.jiodate;
var html5weakmap = new WeakMap();
function EventTarget() {
html5weakmap.set(this, Object.create(null));
};
EventTarget.prototype.addEventListener = function (type, listener) {
if (typeof listener !== 'function') {
return;
}
var em = html5weakmap.get(this);
type = type.toString();
if (em[type]) {
em[type].push(listener);
} else {
em[type] = [listener];
}
};
EventTarget.prototype.removeEventListener = function (type, listener) {
if (typeof listener !== 'function') {
return;
}
var em = html5weakmap.get(this),
i,
listeners = em[type];
type = type.toString();
if (listeners) {
for (i = 0; i < listeners.length; ++i) {
if (listeners[i] === listener) {
if (listeners.length === 1) {
delete em[type];
return;
}
listeners.splice(i, 1);
return;
}
}
}
};
EventTarget.prototype.dispatchEvent = function (event) {
var type = event.type.toString(),
em = html5weakmap.get(this),
ontype = 'on' + type,
i,
listeners;
if (typeof this[ontype] === 'function') {
try {
this[ontype](event);
} catch (ignore) {}
}
listeners = em[type];
if (listeners) {
for (i = 0; i < listeners.length; ++i) {
try {
listeners[i](event);
} catch (ignore) {}
}
}
};
function Blob(blobParts, options) {
// https://developer.mozilla.org/en-US/docs/Web/API/Blob
var i,
priv = {},
buffers = [];
html5weakmap.set(this, priv);
for (i = 0; i < blobParts.length; ++i) {
if (Buffer.isBuffer(blobParts[i])) {
buffers.push(blobParts[i]);
} else if (blobParts[i] instanceof Blob) {
buffers.push(html5weakmap.get(blobParts[i]).data);
} else if (blobParts[i] instanceof ArrayBuffer) {
buffers.push(new Buffer(new Uint8Array(blobParts[i])));
} else {
buffers.push(new Buffer('' + blobParts[i]));
}
}
priv.data = Buffer.concat(buffers);
Object.defineProperty(this, 'size', {
enumerable: true,
value: priv.data.length
});
Object.defineProperty(this, 'type', {
enumerable: true,
value: options ? '' + (options.type || '') : ''
});
};
Blob.prototype.size = 0;
Blob.prototype.type = '';
Blob.prototype.slice = function (start, end, contentType) {
return new Blob([html5weakmap.get(this).data.slice(start, end)], {
type: contentType
});
};
window.Blob = Blob;
function FileReader() {
EventTarget.call(this);
};
FileReader.prototype = Object.create(EventTarget.prototype);
Object.defineProperty(FileReader, 'constructor', {
value: FileReader
});
FileReader.prototype.readAsText = function (blob) {
var target = this,
priv = html5weakmap.get(blob),
result = priv.data.toString(),
event = Object.freeze({
type: 'load',
target: target
});
process.nextTick(function () {
target.result = result;
target.dispatchEvent(event);
});
};
FileReader.prototype.readAsArrayBuffer = function (blob) {
var target = this,
priv = html5weakmap.get(blob),
result = new Uint8Array(priv.data).buffer,
event = Object.freeze({
type: 'load',
target: target
});
process.nextTick(function () {
target.result = result;
target.dispatchEvent(event);
});
};
FileReader.prototype.readAsDataURL = function (blob) {
var target = this,
priv = html5weakmap.get(blob),
result = 'data:' + blob.type + ';base64,' + priv.data.toString('base64'),
event = Object.freeze({
type: 'load',
target: target
});
process.nextTick(function () {
target.result = result;
target.dispatchEvent(event);
});
};
function atob(str) {
try {
return window.atob(str);
}
catch (err) {
var buffer;
if (str instanceof Buffer) {
buffer = str;
}
else {
buffer = Buffer.from(str.toString(), 'base64');
}
return buffer.toString('binary');
}
}
function btoa(str) {
try {
return window.btoa(str);
}
catch (err) {
var buffer;
if (str instanceof Buffer) {
buffer = str;
}
else {
buffer = Buffer.from(str.toString(), 'binary');
}
return buffer.toString('base64');
}
}
module.exports = jIO;
module.exports = window;
} ({}));
\ No newline at end of file
}());
var RSVP = window.RSVP,
moment = window.moment;
\ No newline at end of file
var RSVP = require('RSVP'),
moment = require('moment'),
Rusha = require('rusha'),
XMLHttpRequest = require('xhr2'),
FormData = require('form-data'),
URI = require('urijs'),
UriTemplate = require('uritemplate'),
process = require('process');
window.FormData = FormData;
(function (global) {
(function () {
var window = {},
Blob = null,
EventTarget = null,
Blob = null,
FileReader = null,
atob = null,
btoa = null,
navigator = null;
\ No newline at end of file
navigator = {};
var QueryFactory = window.QueryFactory,
Query = window.Query;
\ No newline at end of file
Query = window.Query,
SimpleQuery = window.SimpleQuery,
ComplexQuery = window.ComplexQuery;
var dist = require('../dist/jio-node-latest');
Object.keys(dist).forEach(key => global[key] = dist[key]);
var sinon = require('sinon');
global.sinon = sinon;
const testrunner = require('qunit');
testrunner.setup({
log: {
errors: true,
summary: true,
tests: true
}
});
testrunner.run({
code: 'test/node-require.js',
tests: [
'test/jio.storage/erp5storage.tests.js',
'test/jio.storage/memorystorage.tests.js',
'test/jio.storage/querystorage.tests.js',
'test/jio.storage/replicatestorage.tests.js',
'test/jio.storage/uuidstorage.tests.js'
]
}, function(err, _report) {
if (err) {
console.error('error', err);
}
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment