1- import { afterEach , describe , expect , it , vi } from 'vitest' ;
1+ import { afterEach , beforeEach , describe , expect , it , MockInstance , vi } from 'vitest' ;
22
3- import { assertDeprecated } from './assert.js' ;
3+ import { assertDeprecated , assertNotRuntime } from './assert.js' ;
44
5- describe ( '#assertDeprecated()' , ( ) => {
6- const consoleMock = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
5+ let consoleMock : MockInstance ;
6+ beforeEach ( ( ) => {
7+ consoleMock = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
8+ } ) ;
79
8- afterEach ( ( ) => {
9- vi . clearAllMocks ( ) ;
10- } ) ;
10+ afterEach ( ( ) => {
11+ vi . clearAllMocks ( ) ;
12+ } ) ;
1113
14+ describe ( 'assertDeprecated()' , ( ) => {
1215 it ( 'prints warning with name and message when condition is false' , ( ) => {
1316 assertDeprecated ( false , 'example-flag' , 'This is an example message.' ) ;
1417
@@ -33,3 +36,29 @@ describe('#assertDeprecated()', () => {
3336 expect ( consoleMock ) . not . toHaveBeenCalled ( ) ;
3437 } ) ;
3538} ) ;
39+
40+ describe ( 'assertNotRuntime()' , ( ) => {
41+ it ( 'prints warning with name and message when condition is false' , ( ) => {
42+ assertNotRuntime ( false , 'example-flag' , 'This is an example message.' ) ;
43+
44+ expect ( consoleMock ) . toHaveBeenLastCalledWith (
45+ '[concurrently] Running via example-flag is not well supported. This is an example message.' ,
46+ ) ;
47+ } ) ;
48+
49+ it ( 'prints same warning only once' , ( ) => {
50+ assertNotRuntime ( false , 'example-flag' , 'This is an example message.' ) ;
51+ assertNotRuntime ( false , 'different-flag' , 'This is another message.' ) ;
52+
53+ expect ( consoleMock ) . toBeCalledTimes ( 1 ) ;
54+ expect ( consoleMock ) . toHaveBeenLastCalledWith (
55+ '[concurrently] Running via different-flag is not well supported. This is another message.' ,
56+ ) ;
57+ } ) ;
58+
59+ it ( 'prints nothing if condition is true' , ( ) => {
60+ assertNotRuntime ( true , 'example-flag' , 'This is an example message.' ) ;
61+
62+ expect ( consoleMock ) . not . toHaveBeenCalled ( ) ;
63+ } ) ;
64+ } ) ;
0 commit comments