Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
WIKIPEDIA
/
nodejs
/
daily_store_reports_nodejs
/
node_modules
/
proxyquire
/
examples
/
simple
:
foo.test.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
'use strict' var path = require('path') require('../example-utils').listModuleAndTests(path.resolve(__dirname, '/foo.js'), __filename) var proxyquire = require('../..') var assert = require('assert') var pathStub = { } // when not overridden, path.extname behaves normally var foo = proxyquire('./foo', { path: pathStub }) assert.strictEqual(foo.extnameAllCaps('file.txt'), '.TXT') // override path.extname pathStub.extname = function (file) { return 'Exterminate, exterminate the ' + file } // path.extname now behaves as we told it to assert.strictEqual(foo.extnameAllCaps('file.txt'), 'EXTERMINATE, EXTERMINATE THE FILE.TXT') // path.basename and all other path module methods still function as before assert.strictEqual(foo.basenameAllCaps('/a/b/file.txt'), 'FILE.TXT') console.log('*** All asserts passed ***')