-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bdf3c6
commit 0a136d3
Showing
14 changed files
with
1,553 additions
and
2,027 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import checkMatcher from './utils/check-matcher'; | ||
import { getDeprecations, getDeprecationsDuringCallback } from '@ember/test-helpers'; | ||
|
||
export default function expectNoDeprecation(cb, matcher) { | ||
const test = (deprecations, matcher) => { | ||
const matchedDeprecations = deprecations.filter(deprecation => { | ||
return checkMatcher(deprecation.message, matcher); | ||
}); | ||
|
||
this.pushResult({ | ||
result: matchedDeprecations.length === 0, | ||
actual: matchedDeprecations, | ||
expected: [], | ||
message: 'Expected no deprecations during test, but deprecations were found.', | ||
}); | ||
} | ||
|
||
if (typeof cb !== 'function') { | ||
// cb is not a callback, so we assume it is the matcher | ||
test(getDeprecations(), cb); | ||
} else { | ||
const maybeThenable = getDeprecationsDuringCallback(cb); | ||
if (maybeThenable !== null && typeof maybeThenable === 'object' && typeof maybeThenable.then === 'function') { | ||
return maybeThenable.then(deprecations => test(deprecations, matcher)); | ||
} else { | ||
test(maybeThenable, matcher); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,59 @@ | ||
import { end, _currentRunloop, _hasScheduledTimers, _cancelTimers } from '@ember/runloop'; | ||
import { run, end, _getCurrentRunLoop, _hasScheduledTimers, _cancelTimers } from '@ember/runloop'; | ||
|
||
function getCurrentRunLoop() { | ||
// Ember 3.24.4 does not have _getCurrentRunLoop, but does have run.currentRunLoop; | ||
if ('currentRunLoop' in run) { | ||
return run.currentRunLoop; | ||
} else { | ||
return _getCurrentRunLoop(); | ||
} | ||
} | ||
|
||
// TODO: It seems very odd to mix runloop + timers into a runloop | ||
// specific assertion. | ||
// | ||
// We should likely: | ||
// | ||
// * have timer specific expectations | ||
// * have runloop specific expectations | ||
// * not have either cancel timers or runloop, rather those should | ||
// be the explicitly choosen by the user | ||
export default function expectNoRunloop() { | ||
if (_currentRunLoop) { | ||
if (getCurrentRunLoop()) { | ||
this.pushResult({ | ||
result: false, | ||
actual: run.currentRunLoop, | ||
actual: getCurrentRunLoop(), | ||
expected: null, | ||
message: 'Should not be in a run loop at end of test' | ||
message: 'expected no active runloop' | ||
}); | ||
|
||
while (_currentRunLoop) { | ||
while (getCurrentRunLoop()) { | ||
end(); | ||
} | ||
} else { | ||
this.pushResult({ | ||
result: true, | ||
actual: null, | ||
expected: null, | ||
message: 'expected no active runloop' | ||
}); | ||
} | ||
|
||
if (_hasScheduledTimers()) { | ||
this.pushResult({ | ||
result: false, | ||
actual: true, | ||
expected: false, | ||
message: 'Ember run should not have scheduled timers at end of test' | ||
message: 'expected no active timers' | ||
}); | ||
|
||
_cancelTimers(); | ||
} else { | ||
this.pushResult({ | ||
result: true, | ||
actual: false, | ||
expected: false, | ||
message: 'expected no active timers' | ||
}); | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
...-support/assertions/expect-no-warnings.js → ...t-support/assertions/expect-no-warning.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = (app) => app.get('/', (_, res) => res.redirect('/tests')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.