module.exports = JS.Test.asyncSteps({ start: function(port, callback) { this._server = new Restore({store: this.store, http: {port: port}}) this._port = port this._server.boot() process.nextTick(callback) }, stop: function(callback) { this._server.stop() process.nextTick(callback) }, header: function(name, value, callback) { this._headers = this._headers || {} this._headers[name] = value process.nextTick(callback) }, get: function(path, params, callback) { request(this, "localhost", this._port, "GET", path, params, this._headers, callback) }, post: function(path, params, callback) { request(this, "localhost", this._port, "POST", path, params, this._headers, callback) }, put: function(path, params, callback) { request(this, "localhost", this._port, "PUT", path, params, this._headers, callback) }, delete: function(path, params, callback) { request(this, "localhost", this._port, "DELETE", path, params, this._headers, callback) }, options: function(path, params, callback) { request(this, "localhost", this._port, "OPTIONS", path, params, this._headers, callback) }, check_status: function(status, callback) { this.assertEqual(status, this.response.statusCode) process.nextTick(callback) }, check_header: function(name, value, callback) { var header = this.response.headers[name.toLowerCase()] if (typeof value === "string") this.assertEqual(value, header) else this.assertMatch(value, header) process.nextTick(callback) }, check_redirect: function(url, callback) { this.assertEqual(302, this.response.statusCode); this.assertEqual(url, this.response.headers.location); process.nextTick(callback); }, check_body: function(expectedBody, callback) { var actualBody = this.response.body.replace(/^\s*|\s*$/g, '') if (typeof expectedBody === "string") this.assertEqual(expectedBody, actualBody) else if (expectedBody.equals) this.assertEqual(expectedBody, this.response.buffer) else this.assertMatch(expectedBody, actualBody) process.nextTick(callback) }, check_json: function(data, callback) { this.assertEqual(data, JSON.parse(this.response.body)) process.nextTick(callback) } })
var JS = require("jstest") require("./async_callbacks_spec") require("./async_steps_spec") require("./async_series_spec") require("./async_continuables_spec") JS.Test.autorun()
JS.Test.describe('Storage Server(Continuables)', function () { this.include(steps) this.before(function (resume) { async.series([this.startServer(4180)], resume) }) this.after(function (resume) { async.series([ this.clearData(), this.stopServer() ], resume) }) this.it('puts and gets data', function (resume) { async.series([ this.put('mol', {value: 42}), this.get('mol'), this.checkBody('42') ], resume) }) this.it('deletes all data', function (resume) { async.series([ this.put('mol', {value: 42}), this.clearData(), this.get('mol') ], resume) }) })
JS.Test.describe('exact linear algebra', function() { this.describe('over fields:', function() { const ops = types.rationalLinearAlgebra; this.describe('the linear equation system solver', function() { this.it('returns a correct solution if any', properties.solverResult(ops)); }); this.describe('the nullSpace operator', function() { this.it('determines the correct null space rank', properties.nullSpaceRank(ops)); this.it('returns a correct solution if any', properties.nullSpaceResult(ops)); }); this.describe('the inverse operator', function() { this.it('finds a result exactly for inputs of full rank', properties.inverseRank(ops)); this.it('returns a correct solution if any', properties.inverseResult(ops)); }); }); this.describe('over modules:', function() { const ops = types.rationalLinearAlgebraModular; this.describe('the linear equation system solver', function() { this.it('returns a correct solution if any', properties.solverResult(ops)); }); this.describe('the nullSpace operator', function() { this.it('determines the correct null space rank', properties.nullSpaceRank(ops)); this.it('returns a correct solution if any', properties.nullSpaceResult(ops)); }); this.describe('the inverse operator', function() { this.it('returns a correct solution if any', properties.inverseResult(ops)); }); }); });
JS.Test.describe('Storage Server (async series)', function () { this.include(steps) this.before(function (resume) { var self = this async.series([ function (cb) { self.startServer(4180, cb) } ], resume) }) this.after(function (resume) { var self = this async.series([ function (cb) {self.stopServer(cb)} ], resume) }) this.it('saves and retrieves a value', function (resume) { var self = this async.series([ function (cb) {self.put('meaning_of_life', {value: '42'}, cb)}, function (cb) {self.get('meaning_of_life', cb)}, function (cb) {self.checkBody('42', cb)} ], resume) }) this.it('deletes all values', function (resume) { var self = this async.series([ function (cb) { self.put('meaning_of_life', {value: '42'}, cb) }, function (cb) { self.clearData(cb) }, function (cb) { self.get('meaning_of_life', cb) } ], resume) }) })
var jstest = require("jstest").Test require("./tests/store_spec") require("./tests/util/binary_search_spec") require("./tests/util/mutex_spec") require("./tests/util/parse_path_spec") require("./tests/util/querystring_spec") require("./tests/adapters/adapter_examples") require("./tests/adapters/dropbox/adapter_spec") require("./tests/adapters/file_spec") require("./tests/adapters/remote_storage/adapter_spec") require("./tests/adapters/remote_storage/node_authorization_spec") require("./tests/adapters/remote_storage/discover_spec") require("./tests/util/request/node_request_spec") jstest.autorun()
var Upcase = samples.Upcase var Filter = samples.Filter var concat = require('concat-stream') JS.Test.describe('Source events', function () { this.before(function () { this.stream = new Source(['a', 'b', 'c'], 10) this.stream.setEncoding('utf8') }) this.it('yields output via the data event', function (resume) { var data = [] this.stream.on('data', data.push.bind(data)) this.stream.on('end', function () { resume(function () { this.assertEqual(['a', 'b', 'c'], data) }) }) }) this.it('emits all the output', function (resume) { this.stream.pipe(concat(function (output) { resume(function () { this.assertEqual('abc', output) }) })) }) }) JS.Test.describe('Upcase', function () { this.before(function () { this.source = new Source(['a', 'b', 'c'], 10)