File tree 5 files changed +58
-0
lines changed
5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { getDeprecations } from '@ember/test-helpers' ;
2
+ import toAssertionMessage from './utils/to-assertion-message' ;
3
+
4
+ export default function deprecationsInclude ( expected ) {
5
+ const deprecations = getDeprecations ( ) . map ( toAssertionMessage ) ;
6
+ this . pushResult ( {
7
+ result : deprecations . indexOf ( expected ) > - 1 ,
8
+ actual : deprecations ,
9
+ message : `expected to find \`${ expected } \` deprecation` ,
10
+ } ) ;
11
+ }
Original file line number Diff line number Diff line change
1
+ import { getDeprecationsDuringCallback } from '@ember/test-helpers' ;
2
+ import toAssertionMessage from './utils/to-assertion-message' ;
3
+
4
+ export default async function deprecations ( callback , expectedDeprecations ) {
5
+ const maybeThenable = getDeprecationsDuringCallback ( callback ) ;
6
+
7
+ const operation = ( deprecations ) => {
8
+ this . deepEqual (
9
+ deprecations . map ( toAssertionMessage ) ,
10
+ expectedDeprecations ,
11
+ 'Expected deprecations during test.'
12
+ ) ;
13
+ } ;
14
+
15
+ if (
16
+ typeof maybeThenable === 'object' &&
17
+ maybeThenable !== null &&
18
+ typeof maybeThenable . then === 'function'
19
+ ) {
20
+ operation ( await maybeThenable ) ;
21
+ } else {
22
+ operation ( maybeThenable ) ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ import { getDeprecations } from '@ember/test-helpers' ;
2
+ import toAssertionMessage from './utils/to-assertion-message' ;
3
+
4
+ export default function noDeprecations ( ) {
5
+ this . deepEqual (
6
+ getDeprecations ( ) . map ( toAssertionMessage ) ,
7
+ [ ] ,
8
+ 'Expected no deprecations during test.'
9
+ ) ;
10
+ }
Original file line number Diff line number Diff line change
1
+ export default function toAssertionMessage ( assertion ) {
2
+ return assertion . message ;
3
+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,16 @@ import { installTestNotIsolatedHook } from './test-isolation-validation';
27
27
28
28
let waitForSettled = true ;
29
29
30
+ import deprecationsInclude from './asserts/deprecations-include' ;
31
+ import deprecations from './asserts/deprecations' ;
32
+ import noDeprecations from './asserts/no-depreactions' ;
33
+
34
+ export function setup ( assert ) {
35
+ assert . deprecationsInclude = deprecationsInclude ;
36
+ assert . deprecations = deprecations ;
37
+ assert . noDeprecations = noDeprecations ;
38
+ }
39
+
30
40
export function setupTest ( hooks , _options ) {
31
41
let options =
32
42
_options === undefined
You can’t perform that action at this time.
0 commit comments