mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-04 10:50:59 +01:00
Added tests to run in browser (no CI yet)
This commit is contained in:
parent
76b520d122
commit
9af504523f
8 changed files with 158 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
doc/
|
||||
node_modules/
|
||||
coverage/
|
||||
test/browser/pako.js
|
||||
v8.log
|
||||
|
|
|
@ -3,3 +3,4 @@ node_modules/
|
|||
benchmark/implementations
|
||||
coverage/
|
||||
dist/
|
||||
test/browser/pako.js
|
||||
|
|
5
Makefile
5
Makefile
|
@ -29,6 +29,11 @@ lint:
|
|||
test: lint
|
||||
mocha
|
||||
|
||||
test-browser: lint
|
||||
rm -f ./test/browser/pako.js
|
||||
browserify -r ./ -s pako > test/browser/pako.js
|
||||
@SAUCE_PROJ=${GITHUB_PROJ} test/browser/sauce-run.js
|
||||
|
||||
cover:
|
||||
rm -rf cover
|
||||
istanbul cover node_modules/.bin/_mocha -- -t 30000 -R spec
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
"devDependencies" : {
|
||||
"mocha": "*",
|
||||
"chai": "*",
|
||||
"benchmark": "*",
|
||||
"ansi": "*",
|
||||
"browserify":"*",
|
||||
|
@ -24,6 +25,10 @@
|
|||
"istanbul": "*",
|
||||
"ndoc": "*",
|
||||
"lodash": "2.4.1",
|
||||
"async": "0.2.10"
|
||||
"async": "0.2.10",
|
||||
|
||||
"mocha-cloud": "*",
|
||||
"mocha-cloud-grid-view": "*",
|
||||
"term-canvas": "*"
|
||||
}
|
||||
}
|
||||
|
|
14
test/browser/browsers.json
Normal file
14
test/browser/browsers.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{ "browserName": "iphone", "platform": "OS X 10.8", "version": "6" },
|
||||
{ "browserName": "android", "platform": "Linux", "version": "4.0" },
|
||||
{ "browserName": "firefox", "platform": "XP" },
|
||||
{ "browserName": "chrome", "platform": "XP" },
|
||||
|
||||
{ "browserName": "internet explorer", "platform": "WIN8", "version": "10" },
|
||||
{ "browserName": "internet explorer", "platform": "VISTA", "version": "9" },
|
||||
{ "browserName": "internet explorer", "platform": "Windows 7","version": "8" },
|
||||
{ "browserName": "internet explorer", "platform": "XP", "version": "7" },
|
||||
|
||||
{ "browserName": "opera", "platform": "Windows 2008","version": "12" },
|
||||
{ "browserName": "safari", "platform": "OS X 10.8", "version": "6" }
|
||||
]
|
77
test/browser/sauce-run.js
Executable file
77
test/browser/sauce-run.js
Executable file
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/* You have to setup 3 enviroment variables to run this script:
|
||||
*
|
||||
* SAUCE_PROJ - project name
|
||||
* SAUCE_USER - saucelabs user name
|
||||
* SAUCE_AUTH - saucelabs authorisation token
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var Cloud = require('mocha-cloud');
|
||||
/* , Canvas = require('term-canvas')
|
||||
, size = process.stdout.getWindowSize()
|
||||
, GridView = require('mocha-cloud-grid-view');*/
|
||||
|
||||
/*if (!process.env.SAUCE_PROJ || !process.env.SAUCE_USER || !process.env.SAUCE_AUTH) {
|
||||
console.err('You must set enviroment variables SAUCE_PROJ, SAUCE_USER and SAUCE_AUTH');
|
||||
process.exit(1);
|
||||
}*/
|
||||
|
||||
var cloud = new Cloud(process.env.SAUCE_PROJ, process.env.SAUCE_USER, process.env.SAUCE_AUTH);
|
||||
|
||||
// the browsers to test
|
||||
|
||||
var browsers = require('./browsers.json');
|
||||
|
||||
browsers.forEach(function(browser) {
|
||||
cloud.browser(browser.browserName, browser.version, browser.platform);
|
||||
});
|
||||
|
||||
// the local url to test
|
||||
|
||||
cloud.url('http://localhost:3000/test/browser/');
|
||||
|
||||
// setup
|
||||
|
||||
/*var canvas = new Canvas(size[0], size[1]);
|
||||
var ctx = canvas.getContext('2d');
|
||||
var grid = new GridView(cloud, ctx);
|
||||
grid.size(canvas.width, canvas.height);
|
||||
ctx.hideCursor();
|
||||
|
||||
// trap SIGINT
|
||||
|
||||
process.on('SIGINT', function(){
|
||||
ctx.reset();
|
||||
process.nextTick(function(){
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
|
||||
// output failure messages
|
||||
// once complete, and exit > 0
|
||||
// accordingly
|
||||
|
||||
cloud.start(function(){
|
||||
grid.showFailures();
|
||||
setTimeout(function(){
|
||||
ctx.showCursor();
|
||||
process.exit(grid.totalFailures());
|
||||
}, 100);
|
||||
});*/
|
||||
|
||||
cloud.on('init', function(browser){
|
||||
console.log(' init : %s %s', browser.browserName, browser.version);
|
||||
});
|
||||
|
||||
cloud.on('start', function(browser){
|
||||
console.log(' start : %s %s', browser.browserName, browser.version);
|
||||
});
|
||||
|
||||
cloud.on('end', function(browser, res){
|
||||
console.log(' end : %s %s : %d failures', browser.browserName, browser.version, res.failures);
|
||||
});
|
||||
|
||||
cloud.start();
|
28
test/browser/test.html
Normal file
28
test/browser/test.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>pako tests</title>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="../../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../../node_modules/chai/chai.js"></script>
|
||||
<script src="./pako.js"></script>
|
||||
<script>
|
||||
mocha.ui('bdd');
|
||||
mocha.reporter('html');
|
||||
assert = chai.assert;
|
||||
</script>
|
||||
<script src="test.js"></script>
|
||||
<script>
|
||||
if (window.mochaPhantomJS) {
|
||||
mochaPhantomJS.run();
|
||||
} else {
|
||||
mocha.run();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
26
test/browser/test.js
Normal file
26
test/browser/test.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*global describe, it, pako, assert*/
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
var size = 100*1000;
|
||||
|
||||
var data_bin = Uint8Array ? new Uint8Array(size) : new Array(size);
|
||||
|
||||
for (var i=data_bin.length-1; i>=0; i--) { data_bin[i] = (Math.random(256)*256) & 0xff; }
|
||||
|
||||
|
||||
describe('Generic tests', function () {
|
||||
|
||||
it('dummy', function() {
|
||||
pako.deflate(data_bin);
|
||||
});
|
||||
|
||||
it.skip('levels', function() {
|
||||
assert.deepEqual(data_bin, pako.inflate(pako.deflate(data_bin)));
|
||||
assert.deepEqual(data_bin, pako.inflate(pako.deflate(data_bin, { level: 0 })));
|
||||
assert.deepEqual(data_bin, pako.inflate(pako.deflate(data_bin, { level: 1 })));
|
||||
});
|
||||
});
|
||||
|
Loading…
Add table
Reference in a new issue