describe("splitfilename", function() local nextfile = require "nextfile" it("should return the filename and extension of an absolute filepath", function() local name, ext = nextfile.splitfilename("/testdir/701.txt") assert.are.equal("701", name) assert.are.equal("txt", ext) end) it("should return the filename and extension of a relative filepath", function() local name, ext = nextfile.splitfilename("../../foo/testdir/file.mp3") assert.are.equal("file", name) assert.are.equal("mp3", ext) end) end) describe("nextfile", function() local prevfile = require "prevfile" local nextfile = require "nextfile" insulate("prevfile.prevfile returns nil", function() prevfile.prevfile = function() return nil end it("should call prevfile.prevfile", function() spy.on(prevfile, "prevfile") test_directory = "/testdir" nextfile.nextfile(test_directory) assert.spy(prevfile.prevfile).was_called_with(test_directory) end) it("should return nil", function() local file = nextfile.nextfile("/testdir") assert.are.equal(nil, file) end) end) --insulate("prevfile.prevfile returns a numeric filename", function() --prevfile.prevfile = function() return "/testdir/701.txt" end -- --it("should return the result of incrementing the filename", function() --local file = nextfile.nextfile("/testdir") -- --assert.are.equal("/testdir/702.txt", file) --end) --end) end)