Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 11 additions & 22 deletions integrations/jasmine-check/jasmine-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,20 @@ function checkIt(it) {
// Intercept match results
var matchFailed = false;
var matchResults = [];
var failingMatchResults;

var addResult = spec.addMatcherResult ?
spec.addMatcherResult.bind(spec) :
spec.addExpectationResult.bind(spec, false);
var expectationResults = [];

var existingSpecFail = spec.fail;
var existingAddExpectationResult = spec.addExpectationResult;
var existingAddMatcherResult = spec.addMatcherResult;

var checkAddExpectationResult = function(passed, data) {
if (passed) {
return;
}
matchFailed = true;
matchResults.push(data);
var checkAddExpectationResult = function(passed, data, isException) {
matchFailed = matchFailed || !passed;
expectationResults.push([passed, data, isException]);
};

var checkAddMatcherResult = function(result) {
matchFailed = matchFailed || !result.passed();
matchResults.push(result);
if (!result.passed()) {
matchFailed = true;
}
};

// Build property
Expand All @@ -96,16 +87,11 @@ function checkIt(it) {
spec.fail = logException;
spec.addExpectationResult = checkAddExpectationResult;
spec.addMatcherResult = checkAddMatcherResult;
matchFailed = false;
matchResults = [];
try {
propertyFn.apply(thisArg, arguments);
} catch (error) {
spec.fail(error);
}
if (matchFailed) {
failingMatchResults = matchResults;
}
spec.fail = existingSpecFail;
spec.addExpectationResult = existingAddExpectationResult;
spec.addMatcherResult = existingAddMatcherResult;
Expand All @@ -129,8 +115,11 @@ function checkIt(it) {
}

// Report results
(failingMatchResults || matchResults).forEach(function (matchResult) {
addResult(matchResult);
matchResults.forEach(function (matchResult) {
spec.addMatcherResult(matchResult);
});
expectationResults.forEach(function(data) {
spec.addExpectationResult(data[0], data[1], data[2]);
});
}
}
Expand All @@ -150,7 +139,7 @@ function logException(e) {
expected: "",
actual: "",
error: e
});
}, true);
}
}

Expand Down