-
Notifications
You must be signed in to change notification settings - Fork 774
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix copy(Sync)Fallback tests for real
- Loading branch information
Maxime Bargiel
committed
Sep 10, 2019
1 parent
a37f89b
commit 182e112
Showing
2 changed files
with
39 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
const fs = require('../../') | ||
const fs = require('graceful-fs') | ||
const path = require('path') | ||
|
||
/* global describe */ | ||
/* global describe, beforeEach, afterEach */ | ||
|
||
if (typeof fs.copyFileSync === 'function') { | ||
// Also load copy-sync tests without fs.copyFileSync | ||
describe('> when using copyFileSyncFallback', () => { | ||
const originalCopyFile = fs.copyFileSync | ||
// Also load copy tests without fs.copyFileSync | ||
describe('> when using copyFileFallback', () => { | ||
const originalCopyFileSync = fs.copyFileSync | ||
|
||
beforeEach(() => { | ||
// reset stubs | ||
delete fs.copyFileSync | ||
}) | ||
|
||
afterEach(() => { | ||
fs.copyFileSync = originalCopyFileSync | ||
}) | ||
|
||
delete fs.copyFileSync | ||
const fallbackTest = path.basename(__filename) | ||
try { | ||
fs.readdirSync(__dirname) | ||
.filter(filename => filename.endsWith('.test.js') && filename !== fallbackTest) | ||
.map(filename => { | ||
const testModule = `./${filename}` | ||
delete require.cache[require.resolve(testModule)] | ||
require(testModule) | ||
}) | ||
} finally { | ||
fs.copyFileSync = originalCopyFile | ||
} | ||
fs.readdirSync(__dirname) | ||
.filter(filename => filename.endsWith('.test.js') && filename !== fallbackTest) | ||
.map(filename => { | ||
const testModule = `./${filename}` | ||
delete require.cache[require.resolve(testModule)] | ||
require(testModule) | ||
}) | ||
}) | ||
} |
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,25 +1,29 @@ | ||
const fs = require('../../') | ||
const fs = require('graceful-fs') | ||
const path = require('path') | ||
|
||
/* global describe */ | ||
/* global describe, beforeEach, afterEach */ | ||
|
||
if (typeof fs.copyFile === 'function') { | ||
// Also load copy tests without fs.copyFile | ||
describe('> when using copyFileFallback', () => { | ||
const originalCopyFile = fs.copyFile | ||
|
||
delete fs.copyFile | ||
const fallbackTest = path.basename(__filename) | ||
try { | ||
fs.readdirSync(__dirname) | ||
.filter(filename => filename.endsWith('.test.js') && filename !== fallbackTest) | ||
.map(filename => { | ||
const testModule = `./${filename}` | ||
delete require.cache[require.resolve(testModule)] | ||
require(testModule) | ||
}) | ||
} finally { | ||
beforeEach(() => { | ||
// reset stubs | ||
delete fs.copyFile | ||
}) | ||
|
||
afterEach(() => { | ||
fs.copyFile = originalCopyFile | ||
} | ||
}) | ||
|
||
const fallbackTest = path.basename(__filename) | ||
fs.readdirSync(__dirname) | ||
.filter(filename => filename.endsWith('.test.js') && filename !== fallbackTest) | ||
.map(filename => { | ||
const testModule = `./${filename}` | ||
delete require.cache[require.resolve(testModule)] | ||
require(testModule) | ||
}) | ||
}) | ||
} |