Merge pull request #4962 from tschaub/untestable

Skip tests where features are not available
This commit is contained in:
Tim Schaub
2016-03-02 15:21:36 -07:00
4 changed files with 89 additions and 67 deletions

View File

@@ -6,6 +6,7 @@
"afterLoadText": false,
"expect": false,
"proj4": false,
"sinon": false
"sinon": false,
"where": false
}
}

View File

@@ -1,7 +1,6 @@
goog.provide('ol.test.format.MVT');
(typeof ArrayBuffer == 'function' ? describe : xdescribe)('ol.format.MVT',
function() {
where('ArrayBuffer').describe('ol.format.MVT', function() {
var data;
beforeEach(function(done) {
@@ -68,7 +67,7 @@ goog.provide('ol.test.format.MVT');
});
});
});
goog.require('ol.Feature');

View File

@@ -9,7 +9,7 @@ var green = 'data:image/gif;base64,R0lGODlhAQABAPAAAAD/AP///yH5BAAAAAAALAAAA' +
var blue = 'data:image/gif;base64,R0lGODlhAQABAPAAAAAA/////yH5BAAAAAAALAAAAA' +
'ABAAEAAAICRAEAOw==';
describe('ol.source.Raster', function() {
where('Uint8ClampedArray').describe('ol.source.Raster', function() {
var target, map, redSource, greenSource, blueSource, raster;

View File

@@ -458,4 +458,26 @@
}
};
var features = {
ArrayBuffer: typeof ArrayBuffer === 'function',
Uint8ClampedArray: ('Uint8ClampedArray' in global)
};
/**
* Allow tests to be skipped where certain features are not available. The
* provided key must be in the above `features` lookup. Keys should
* correspond to the feature that is required, but can be any string.
* @param {string} key The required feature name.
* @return {Object} An object with a `describe` function that will run tests
* if the required feature is available and skip them otherwise.
*/
global.where = function(key) {
if (!(key in features)) {
throw new Error('where() called with unknown key: ' + key);
}
return {
describe: features[key] ? global.describe : global.xdescribe
};
};
})(this);