From 4b04360b0d9eb8509b367fed9f40f09a03eab9e1 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Mon, 7 Aug 2017 11:34:01 -0400 Subject: [PATCH] DummyDataApi: Add test class. * test/dapi/DummyDataApi.js: Add class. --- test/dapi/DummyDataApi.js | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 test/dapi/DummyDataApi.js diff --git a/test/dapi/DummyDataApi.js b/test/dapi/DummyDataApi.js new file mode 100644 index 0000000..fbbfcac --- /dev/null +++ b/test/dapi/DummyDataApi.js @@ -0,0 +1,67 @@ +/** + * Applies arbitrary function to response data + * + * Copyright (C) 2017 R-T Specialty, LLC. + * + * This file is part of the Liza Data Collection Framework + * + * Liza is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +const { Class } = require( 'easejs' ); +const { DataApi } = require( '../../' ).dapi; + + +/** + * Dummy DataApi implementation for testing + * + * This should not be used in production. + */ +module.exports = Class( 'DummyDataApi' ) + .implement( DataApi ) + .extend( +{ + /** + * #request callback + * + * @type {Function} #request method callback + */ + 'private _reqCallback': () => {}, + + + /** + * Initialize with `#request` method callback + * + * @param {Function} req_callback #request method callback + */ + constructor( req_callback ) + { + this._reqCallback = req_callback; + }, + + + /** + * Dummy method that invokes the callback provided via constructor + * + * @param {?Object|string} data request params or post data + * @param {function(?Error,*):string} callback continuation upon reply + * + * @return {DataApi} self + */ + 'virtual public request'( data, callback ) + { + this._reqCallback( data, callback ); + return this; + }, +} );