Skip to content

Instantly share code, notes, and snippets.

@cmstead
Last active February 7, 2017 06:48
Show Gist options
  • Save cmstead/418dd9844292709cdfb173a8754141c8 to your computer and use it in GitHub Desktop.
Save cmstead/418dd9844292709cdfb173a8754141c8 to your computer and use it in GitHub Desktop.
Extended test runner for UI tests
(function (testRunner) {
'use strict';
function logAndTestUi(sample, expectedMean, expectedStandardDeviation) {
var message = 'Testing -- ' +
'sample: ' + JSON.stringify(sample) + '; ' +
'expected mean: ' + expectedMean + '; ' +
'expected standard deviation: ' + expectedStandardDeviation;
console.log(message);
return testRunner.testUi(sample, expectedMean, expectedStandardDeviation);
}
function testUiCases() {
var result = null;
// Failing cases
result = logAndTestUi([], NaN, NaN);
result = logAndTestUi([parseFloat('a'), parseFloat('b')], NaN, NaN);
// Passing cases
result = logAndTestUi([1, 2, 1, 2], 1.5, 0.5);
result = logAndTestUi([1, 2, 3, 1, 2, 3], 2, 0.816496580927726);
return result;
}
testRunner.testUiCases = testUiCases;
})(testRunner);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment