@@ -2,19 +2,15 @@ const assert = require('assert');
22const exec = require ( 'executive' ) ;
33const fse = require ( 'fs-extra' ) ;
44const path = require ( 'path' ) ;
5- const { promisify } = require ( 'util' ) ;
65
7- const nsfw = require ( '../src/ ' ) ;
6+ const { DEBOUNCE , TIMEOUT_PER_STEP , WORKDIR : workDir , sleep } = require ( './common ' ) ;
87
9- const DEBOUNCE = 1000 ;
10- const TIMEOUT_PER_STEP = 3000 ;
11-
12- const sleep = promisify ( setTimeout ) ;
8+ const nsfw = require ( '../src' ) ;
139
1410describe ( 'Node Sentinel File Watcher' , function ( ) {
1511 this . timeout ( 120000 ) ;
1612
17- const workDir = path . resolve ( './mockfs ') ;
13+ assert . ok ( typeof nsfw . _native . NSFW_TEST_SLOW === 'undefined' , 'NSFW should NOT be built in slow mode ') ;
1814
1915 beforeEach ( async function ( ) {
2016 async function makeDir ( identifier ) {
@@ -438,47 +434,6 @@ describe('Node Sentinel File Watcher', function() {
438434 } ) ;
439435
440436 describe ( 'Recursive' , function ( ) {
441- it ( 'can listen for the creation of a deeply nested file' , async function ( ) {
442- const paths = [ 'd' , 'e' , 'e' , 'p' , 'f' , 'o' , 'l' , 'd' , 'e' , 'r' ] ;
443- const file = 'a_file.txt' ;
444- let foundFileCreateEvent = false ;
445-
446- function findEvent ( element ) {
447- if (
448- element . action === nsfw . actions . CREATED &&
449- element . directory === path . join ( workDir , ...paths ) &&
450- element . file === file
451- ) {
452- foundFileCreateEvent = true ;
453- }
454- }
455-
456- let watch = await nsfw (
457- workDir ,
458- events => events . forEach ( findEvent ) ,
459- { debounceMS : DEBOUNCE }
460- ) ;
461-
462- try {
463- await watch . start ( ) ;
464- await sleep ( TIMEOUT_PER_STEP ) ;
465- let directory = workDir ;
466- for ( const dir of paths ) {
467- directory = path . join ( directory , dir ) ;
468- await fse . mkdir ( directory ) ;
469- await sleep ( 60 ) ;
470- }
471- const fd = await fse . open ( path . join ( directory , file ) , 'w' ) ;
472- await fse . close ( fd ) ;
473- await sleep ( TIMEOUT_PER_STEP ) ;
474-
475- assert . ok ( foundFileCreateEvent ) ;
476- } finally {
477- await watch . stop ( ) ;
478- watch = null ;
479- }
480- } ) ;
481-
482437 it ( 'can listen for the destruction of a directory and its subtree' , async function ( ) {
483438 const inPath = path . resolve ( workDir , 'test4' ) ;
484439 let deletionCount = 0 ;
0 commit comments