-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃挴 #8
馃挴 #8
Conversation
@digitalBush When I |
spec/behavior/fileLoader.spec.js
Outdated
readFile: sinon.stub() | ||
}; | ||
fs.readFile.onCall( 0 ).callsArgWith( 2, null, expected ); | ||
fs.readFile.onCall( 1 ).throws( new Error( "you failed" ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than setting different behaviors for different calls, would it be simpler just to assert that fs.readFile
is called only once?
src/fileLoader.js
Outdated
@@ -17,7 +17,7 @@ module.exports = function( relativeFile ) { | |||
|
|||
let result = cache[ fileName ]; | |||
if ( !result ) { | |||
result = cache[ fileName ] = readFileAsync( fileName, "utf8" ); | |||
result = cache[ fileName ] = await readFileAsync( fileName, "utf8" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is not part of this PR, but this cache looks like a great place for a Map
.
df3f3e9
to
8a33f57
Compare
@calvinb Made the changes you suggested. npm install was fine for me though. Are you running the latest version of node? |
This brings coverage to 100%
![](https://camo.githubusercontent.com/758b6328c3be121fb4c7740e3bd5030f154a20066c2fd0a3a60ecc7ba0b58a87/687474703a2f2f37382e6d656469612e74756d626c722e636f6d2f39326666366564626263343261323237383962663437613030383661363136392f74756d626c725f696e6c696e655f6e6d3362676543566e373173386c716e672e676966)