Finish test suite changes for node.js
This commit is contained in:
parent
9426a700b5
commit
81b4d26b90
|
@ -1,14 +1,18 @@
|
|||
define(["Filer"], function(Filer) {
|
||||
|
||||
var indexedDB = window.indexedDB ||
|
||||
var indexedDB = (function(window) {
|
||||
return window.indexedDB ||
|
||||
window.mozIndexedDB ||
|
||||
window.webkitIndexedDB ||
|
||||
window.msIndexedDB;
|
||||
}(this));
|
||||
|
||||
var needsCleanup = [];
|
||||
if(typeof window !== 'undefined') {
|
||||
window.addEventListener('beforeunload', function() {
|
||||
needsCleanup.forEach(function(f) { f(); });
|
||||
});
|
||||
}
|
||||
|
||||
function IndexedDBTestProvider(name) {
|
||||
var _done = false;
|
||||
|
|
|
@ -38,7 +38,8 @@ function(Filer, IndexedDBTestProvider, WebSQLTestProvider, MemoryTestProvider) {
|
|||
// (e.g., ?filer-provider=IndexedDB). If not specified, we use
|
||||
// the Memory provider by default. See test/require-config.js
|
||||
// for definition of window.filerArgs.
|
||||
var providerType = window.filerArgs && window.filerArgs.provider ?
|
||||
var providerType = (typeof window !== 'undefined' &&
|
||||
window.filerArgs && window.filerArgs.provider) ?
|
||||
window.filerArgs.provider : 'Memory';
|
||||
|
||||
var name = uniqueName();
|
||||
|
@ -59,7 +60,8 @@ function(Filer, IndexedDBTestProvider, WebSQLTestProvider, MemoryTestProvider) {
|
|||
}
|
||||
|
||||
// Allow passing FS flags on query string
|
||||
var flags = window.filerArgs && window.filerArgs.flags ?
|
||||
var flags = (typeof window !== 'undefined' &&
|
||||
window && window.filerArgs && window.filerArgs.flags) ?
|
||||
window.filerArgs.flags : 'FORMAT';
|
||||
|
||||
// Create a file system and wait for it to get setup
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
define(["Filer"], function(Filer) {
|
||||
|
||||
var needsCleanup = [];
|
||||
if(typeof window !== 'undefined') {
|
||||
window.addEventListener('beforeunload', function() {
|
||||
needsCleanup.forEach(function(f) { f(); });
|
||||
});
|
||||
}
|
||||
|
||||
function WebSQLTestProvider(name) {
|
||||
var _done = false;
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
var requirejs = require('requirejs');
|
||||
// If there's something broken in filer or a test,
|
||||
// requirejs can blow up, and mocha sees it as tests
|
||||
// not getting added (i.e., it just exists with only
|
||||
// 1 test run). Display an error so it's clear what happened.
|
||||
process.on('uncaughtException', function(err) {
|
||||
console.error('Error in require.js trying to build test suite, filer:\n', err.stack);
|
||||
});
|
||||
|
||||
var requirejs = require('requirejs');
|
||||
requirejs.config({
|
||||
paths: {
|
||||
"tests": "../tests",
|
||||
|
@ -22,16 +29,10 @@ requirejs.config({
|
|||
nodeRequire: require
|
||||
});
|
||||
|
||||
GLOBAL.document = {};
|
||||
GLOBAL.navigator = { userAgent: ""};
|
||||
GLOBAL.window = {
|
||||
addEventListener: function(){},
|
||||
navigator: navigator,
|
||||
document: document,
|
||||
setTimeout: setTimeout
|
||||
};
|
||||
// We use Chai's expect assertions in all the tests via a global
|
||||
GLOBAL.expect = require('chai').expect;
|
||||
|
||||
// Workaround for Mocha bug, see https://github.com/visionmedia/mocha/issues/362
|
||||
describe("Mocha needs one test in order to wait on requirejs tests", function() {
|
||||
it('should wait for other tests', function(){
|
||||
require('assert').ok(true);
|
||||
|
|
Loading…
Reference in New Issue