Skip to content

Commit

Permalink
chore: added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelgj committed Apr 16, 2013
1 parent 7061d0c commit 775eb36
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fs.js
Expand Up @@ -249,6 +249,7 @@ var Mock = function(structure) {

this.exists = function(path, callback) {
var existsSync = this.existsSync;

predictableNextTick(function() {
callback(existsSync(path));
});
Expand Down
33 changes: 33 additions & 0 deletions test/fs.spec.coffee
Expand Up @@ -354,3 +354,36 @@ describe 'fs', ->
fs._touchFile '/home/vojta/some.js'

expect(callback).toHaveBeenCalled()


# ===========================================================================
# fs.existsSync
# ===========================================================================
describe 'existsSync', ->

it 'should return true for existing file and false for non-existing', ->
expect(fs.existsSync '/home/vojta/some.js').toBe(true)
expect(fs.existsSync '/home/vojta/non-existing.js').toBe(false)


# ===========================================================================
# fs.exists
# ===========================================================================
describe 'exists', ->

it 'should callback with true for existing file', ->
callback = (exists) ->
expect(exists).toBe(true)
finished++

fs.exists '/home/vojta/some.js', callback
waitForFinished()


it 'should callback with false for none-existing file', ->
callback = (exists) ->
expect(exists).toBe(false)
finished++

fs.exists '/home/vojta/none-existing.js', callback
waitForFinished()

0 comments on commit 775eb36

Please sign in to comment.