@@ -6,6 +6,9 @@ const { runCommands } = require('../../src/command-runner');
6
6
const createRunCommandsSpy = require ( '../helpers/run-commands-spy' ) ;
7
7
const { StdinMock } = require ( './../helpers/mockStdio' ) ;
8
8
9
+ const wait = miliseconds => new Promise ( resolve => setTimeout ( resolve , miliseconds ) ) ;
10
+ const waitForDebounce = ( ) => wait ( 110 ) ;
11
+
9
12
describe ( 'argus' , function argusTestSuite ( ) {
10
13
this . slow ( 500 ) ;
11
14
@@ -42,9 +45,11 @@ describe('argus', function argusTestSuite() {
42
45
fork ( pathToTouchScript , [ path . join ( '.' , 'src' , 'PhpClass.php' ) ] ) ;
43
46
44
47
watcher . on ( 'change' , ( ) => {
45
- assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . command , 'echo' ) ;
46
- assert . deepEqual ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . args , [ 'tests/src/PhpClassTest.php' ] ) ;
47
- done ( ) ;
48
+ waitForDebounce ( ) . then ( ( ) => {
49
+ assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . command , 'echo' ) ;
50
+ assert . deepEqual ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . args , [ 'tests/src/PhpClassTest.php' ] ) ;
51
+ done ( ) ;
52
+ } ) ;
48
53
} ) ;
49
54
} ) ;
50
55
@@ -53,9 +58,11 @@ describe('argus', function argusTestSuite() {
53
58
fork ( pathToTouchScript , [ path . join ( '.' , 'tests' , 'src' , 'PhpClassTest.php' ) ] ) ;
54
59
55
60
watcher . on ( 'change' , ( ) => {
56
- assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . command , 'echo' ) ;
57
- assert . deepEqual ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . args , [ 'tests/src/PhpClassTest.php' ] ) ;
58
- done ( ) ;
61
+ waitForDebounce ( ) . then ( ( ) => {
62
+ assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . command , 'echo' ) ;
63
+ assert . deepEqual ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . args , [ 'tests/src/PhpClassTest.php' ] ) ;
64
+ done ( ) ;
65
+ } ) ;
59
66
} ) ;
60
67
} ) ;
61
68
@@ -65,12 +72,14 @@ describe('argus', function argusTestSuite() {
65
72
66
73
return new Promise ( ( resolve ) => {
67
74
watcher . on ( 'change' , ( ) => {
68
- assert . strictEqual ( runCommandsSpy . getCommandsBatchRunCount ( ) , 1 ) ;
69
- assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . command , 'echo' ) ;
70
- assert . deepEqual ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . args , [ 'tests/src/PhpClassTest.php' ] ) ;
71
-
72
- mockStdin . on ( 'data' , resolve ) ;
73
- mockStdin . push ( 'r' ) ;
75
+ waitForDebounce ( ) . then ( ( ) => {
76
+ assert . strictEqual ( runCommandsSpy . getCommandsBatchRunCount ( ) , 1 ) ;
77
+ assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . command , 'echo' ) ;
78
+ assert . deepEqual ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . args , [ 'tests/src/PhpClassTest.php' ] ) ;
79
+
80
+ mockStdin . on ( 'data' , resolve ) ;
81
+ mockStdin . push ( 'r' ) ;
82
+ } ) ;
74
83
} ) ;
75
84
} ) . then ( ( ) => {
76
85
assert . strictEqual ( runCommandsSpy . getCommandsBatchRunCount ( ) , 2 ) ;
@@ -104,15 +113,17 @@ describe('argus', function argusTestSuite() {
104
113
fork ( pathToTouchScript , [ path . join ( '.' , 'src' , 'Class.php' ) ] ) ;
105
114
106
115
watcher . on ( 'change' , ( ) => {
107
- assert . equal ( runCommandsSpy . getLastRunCommands ( ) . length , 2 , 'Expected only two commands to run' ) ;
108
- assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . command , 'vendor/bin/phpunit' ) ;
109
- assert . deepEqual ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . args , [ 'tests/unit/src/ClassTest.php' ] ) ;
110
- assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 1 ] . command , 'vendor/bin/phpunit' ) ;
111
- assert . deepEqual (
112
- runCommandsSpy . getLastRunCommands ( ) [ 1 ] . args ,
113
- [ '-c' , 'phpunit-integration.xml' , 'tests/integration/src/ClassTest.php' ] ,
114
- ) ;
115
- done ( ) ;
116
+ waitForDebounce ( ) . then ( ( ) => {
117
+ assert . equal ( runCommandsSpy . getLastRunCommands ( ) . length , 2 , 'Expected only two commands to run' ) ;
118
+ assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . command , 'vendor/bin/phpunit' ) ;
119
+ assert . deepEqual ( runCommandsSpy . getLastRunCommands ( ) [ 0 ] . args , [ 'tests/unit/src/ClassTest.php' ] ) ;
120
+ assert . equal ( runCommandsSpy . getLastRunCommands ( ) [ 1 ] . command , 'vendor/bin/phpunit' ) ;
121
+ assert . deepEqual (
122
+ runCommandsSpy . getLastRunCommands ( ) [ 1 ] . args ,
123
+ [ '-c' , 'phpunit-integration.xml' , 'tests/integration/src/ClassTest.php' ] ,
124
+ ) ;
125
+ done ( ) ;
126
+ } ) ;
116
127
} ) ;
117
128
} ) ;
118
129
} ) ;
0 commit comments