mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
fixes for minified version test minified version in SauceLabs
This commit is contained in:
33
Gulpfile.js
33
Gulpfile.js
@@ -13,6 +13,17 @@ var fs = require('fs');
|
||||
|
||||
var pkg = require('./package.json');
|
||||
|
||||
var uglifyOptions = {
|
||||
mangle: {
|
||||
except: ['_', 'RippleError', 'RippledError', 'UnexpectedError',
|
||||
'LedgerVersionError', 'ConnectionError', 'NotConnectedError',
|
||||
'DisconnectedError', 'TimeoutError', 'ResponseFormatError',
|
||||
'ValidationError', 'NotFoundError', 'MissingLedgerHistoryError',
|
||||
'PendingLedgerVersionError'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
function webpackConfig(extension, overrides) {
|
||||
overrides = overrides || {};
|
||||
var defaults = {
|
||||
@@ -85,13 +96,17 @@ gulp.task('build-tests', function(callback) {
|
||||
'integration/'), done);
|
||||
});
|
||||
|
||||
function createLink(from, to) {
|
||||
if (fs.existsSync(to)) {
|
||||
fs.unlinkSync(to);
|
||||
}
|
||||
fs.linkSync(from, to);
|
||||
}
|
||||
|
||||
function createBuildLink(callback) {
|
||||
return function(err, res) {
|
||||
var latestBuildName = './build/ripple-latest.js';
|
||||
if (fs.existsSync(latestBuildName)) {
|
||||
fs.unlinkSync(latestBuildName);
|
||||
}
|
||||
fs.linkSync('./build/ripple-' + pkg.version + '.js', latestBuildName);
|
||||
createLink('./build/ripple-' + pkg.version + '.js',
|
||||
'./build/ripple-latest.js');
|
||||
callback(err, res);
|
||||
};
|
||||
}
|
||||
@@ -102,9 +117,13 @@ gulp.task('build', function(callback) {
|
||||
|
||||
gulp.task('build-min', ['build'], function() {
|
||||
return gulp.src(['./build/ripple-', '.js'].join(pkg.version))
|
||||
.pipe(uglify())
|
||||
.pipe(uglify(uglifyOptions))
|
||||
.pipe(rename(['ripple-', '-min.js'].join(pkg.version)))
|
||||
.pipe(gulp.dest('./build/'));
|
||||
.pipe(gulp.dest('./build/'))
|
||||
.on('end', function() {
|
||||
createLink('./build/ripple-' + pkg.version + '-min.js',
|
||||
'./build/ripple-latest-min.js');
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('build-debug', function(callback) {
|
||||
|
||||
4
npm-shrinkwrap.json
generated
4
npm-shrinkwrap.json
generated
@@ -155,8 +155,8 @@
|
||||
}
|
||||
},
|
||||
"ripple-binary-codec": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.1.1.tgz",
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.1.2.tgz",
|
||||
"dependencies": {
|
||||
"babel-runtime": {
|
||||
"version": "5.8.34",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"jayson": "^1.2.2",
|
||||
"lodash": "^3.1.0",
|
||||
"ripple-address-codec": "^2.0.1",
|
||||
"ripple-binary-codec": "^0.1.1",
|
||||
"ripple-binary-codec": "^0.1.2",
|
||||
"ripple-hashes": "^0.1.0",
|
||||
"ripple-keypairs": "^0.10.0",
|
||||
"ripple-lib-transactionparser": "^0.6.0",
|
||||
|
||||
@@ -36,11 +36,13 @@ unittest() {
|
||||
mocha --opts test-compiled/mocha.opts test-compiled
|
||||
|
||||
# compile tests for browser testing
|
||||
gulp build build-tests
|
||||
gulp build-min build-tests
|
||||
node --harmony test-compiled/mocked-server.js > /dev/null &
|
||||
|
||||
echo "Running tests in PhantomJS"
|
||||
mocha-phantomjs test/localrunner.html
|
||||
echo "Running tests using minified version in PhantomJS"
|
||||
mocha-phantomjs test/localrunnermin.html
|
||||
|
||||
echo "Running tests in SauceLabs"
|
||||
http-server &
|
||||
@@ -56,7 +58,7 @@ integrationtest() {
|
||||
mocha test/integration/http-integration-test.js
|
||||
|
||||
# run integration tests in PhantomJS
|
||||
gulp build-tests build
|
||||
gulp build-tests build-min
|
||||
echo "Running integragtion tests in PhantomJS"
|
||||
mocha-phantomjs test/localintegrationrunner.html
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ function setPrototypeOf(object, prototype) {
|
||||
function getConstructorName(object) {
|
||||
// hack for internet explorer
|
||||
return process.browser ?
|
||||
object.constructor.toString().match(/^function\s(.+)\(/)[1] :
|
||||
object.constructor.toString().match(/^function\s+([^(]*)/)[1] :
|
||||
object.constructor.name;
|
||||
}
|
||||
|
||||
|
||||
37
test/hacks/phantomhacks.js
Normal file
37
test/hacks/phantomhacks.js
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
// this one will be directly run in browser, so disable eslint
|
||||
/* eslint-disable no-var, no-extend-native, consistent-this, func-style */
|
||||
|
||||
(function() {
|
||||
var phantomTest = /PhantomJS/;
|
||||
if (phantomTest.test(navigator.userAgent)) {
|
||||
// mocha-phantomjs-core has wrong shim for Function.bind, so we
|
||||
// will replace it with correct one
|
||||
// this bind polyfill copied from MDN documentation
|
||||
Function.prototype.bind = function(oThis) {
|
||||
if (typeof this !== 'function') {
|
||||
// closest thing possible to the ECMAScript 5
|
||||
// internal IsCallable function
|
||||
throw new TypeError(
|
||||
'Function.prototype.bind - what is trying to be bound is not callable'
|
||||
);
|
||||
}
|
||||
|
||||
var aArgs = Array.prototype.slice.call(arguments, 1);
|
||||
var fToBind = this;
|
||||
var FNOP = function() {};
|
||||
var fBound = function() {
|
||||
return fToBind.apply(this instanceof FNOP ? this : oThis,
|
||||
aArgs.concat(Array.prototype.slice.call(arguments)));
|
||||
};
|
||||
|
||||
if (this.prototype) {
|
||||
// native functions don't have a prototype
|
||||
FNOP.prototype = this.prototype;
|
||||
}
|
||||
fBound.prototype = new FNOP();
|
||||
|
||||
return fBound;
|
||||
};
|
||||
}
|
||||
})();
|
||||
@@ -9,41 +9,7 @@
|
||||
<div id="deb"></div>
|
||||
<div id="mocha"></div>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script>
|
||||
(function() {
|
||||
var phantomTest = /PhantomJS/;
|
||||
if (phantomTest.test(navigator.userAgent)) {
|
||||
// mocha-phantomjs-core has wrong shim for Function.bind, so we
|
||||
// will replace it with correct one
|
||||
// this bind polyfill copied from MDN documentation
|
||||
Function.prototype.bind = function(oThis) {
|
||||
if (typeof this !== 'function') {
|
||||
// closest thing possible to the ECMAScript 5
|
||||
// internal IsCallable function
|
||||
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
|
||||
}
|
||||
|
||||
var aArgs = Array.prototype.slice.call(arguments, 1),
|
||||
fToBind = this,
|
||||
fNOP = function() {},
|
||||
fBound = function() {
|
||||
return fToBind.apply(this instanceof fNOP
|
||||
? this
|
||||
: oThis,
|
||||
aArgs.concat(Array.prototype.slice.call(arguments)));
|
||||
};
|
||||
|
||||
if (this.prototype) {
|
||||
// native functions don't have a prototype
|
||||
fNOP.prototype = this.prototype;
|
||||
}
|
||||
fBound.prototype = new fNOP();
|
||||
|
||||
return fBound;
|
||||
};
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script src="hacks/phantomhacks.js"></script>
|
||||
<script src="../build/ripple-latest.js"></script>
|
||||
<script>
|
||||
if (window.initMochaPhantomJS) {
|
||||
|
||||
@@ -9,41 +9,7 @@
|
||||
<div id="deb"></div>
|
||||
<div id="mocha"></div>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script>
|
||||
(function() {
|
||||
var phantomTest = /PhantomJS/;
|
||||
if (phantomTest.test(navigator.userAgent)) {
|
||||
// mocha-phantomjs-core has wrong shim for Function.bind, so we
|
||||
// will replace it with correct one
|
||||
// this bind polyfill copied from MDN documentation
|
||||
Function.prototype.bind = function(oThis) {
|
||||
if (typeof this !== 'function') {
|
||||
// closest thing possible to the ECMAScript 5
|
||||
// internal IsCallable function
|
||||
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
|
||||
}
|
||||
|
||||
var aArgs = Array.prototype.slice.call(arguments, 1),
|
||||
fToBind = this,
|
||||
fNOP = function() {},
|
||||
fBound = function() {
|
||||
return fToBind.apply(this instanceof fNOP
|
||||
? this
|
||||
: oThis,
|
||||
aArgs.concat(Array.prototype.slice.call(arguments)));
|
||||
};
|
||||
|
||||
if (this.prototype) {
|
||||
// native functions don't have a prototype
|
||||
fNOP.prototype = this.prototype;
|
||||
}
|
||||
fBound.prototype = new fNOP();
|
||||
|
||||
return fBound;
|
||||
};
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script src="hacks/phantomhacks.js"></script>
|
||||
<script src="../build/ripple-latest.js"></script>
|
||||
<script>
|
||||
if (window.initMochaPhantomJS) {
|
||||
|
||||
33
test/localrunnermin.html
Normal file
33
test/localrunnermin.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<!-- encoding must be set for mocha's special characters to render properly -->
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
<script src="./vendor/lodash.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="deb"></div>
|
||||
<div id="mocha"></div>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="hacks/phantomhacks.js"></script>
|
||||
<script src="../build/ripple-latest-min.js"></script>
|
||||
<script>
|
||||
if (window.initMochaPhantomJS) {
|
||||
window.initMochaPhantomJS();
|
||||
}
|
||||
mocha.ui('bdd')
|
||||
</script>
|
||||
|
||||
<script src="../test-compiled-for-web/api-test.js"></script>
|
||||
|
||||
<script src="../test-compiled-for-web/broadcast-api-test.js"></script>
|
||||
|
||||
<script src="../test-compiled-for-web/connection-test.js"></script>
|
||||
|
||||
<script src="../test-compiled-for-web/rangeset-test.js"></script>
|
||||
|
||||
<script>
|
||||
mocha.run()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -10,9 +10,9 @@
|
||||
<div id="mocha"></div>
|
||||
<script src="/node_modules/mocha/mocha.js"></script>
|
||||
|
||||
<script src="/node_modules/mocha-sauce/client.js"></script>
|
||||
<script src="/node_modules/mocha-in-sauce/client.js"></script>
|
||||
|
||||
<script src="/build/ripple-latest.js"></script>
|
||||
<script src="/build/ripple-latest-min.js"></script>
|
||||
<script>
|
||||
mocha.ui('bdd')
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user