{"size": 1097, "ext": "js", "max_stars_repo_path": "node_modules/walk-back/test/test.js", "max_stars_repo_name": "alvaromartinez986/AngularCourse", "max_stars_repo_stars_event_min_datetime": "2015-10-26T09:42:48.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-02T16:44:25.000Z", "max_issues_repo_path": "node_modules/walk-back/test/test.js", "max_issues_repo_name": "alvaromartinez986/AngularCourse", "max_issues_repo_issues_event_min_datetime": "2017-11-15T01:53:24.000Z", "max_issues_repo_issues_event_max_datetime": "2017-12-14T09:09:16.000Z", "max_forks_repo_path": "app/node_modules/walk-back/test/test.js", "max_forks_repo_name": "vendyawards/vendyawards", "max_forks_repo_forks_event_min_datetime": "2021-09-17T18:09:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T22:13:42.000Z"}
{"max_stars_count": 43, "max_issues_count": 36, "max_forks_count": 11, "avg_line_length": 24.3777777778, "max_line_length": 81, "alphanum_fraction": 0.646308113}
var test = require('tape')
var walkBack = require('../')

test('basic', function (t) {
  t.plan(1)

  var filename = walkBack(__dirname + '/fixture/subdir', 'file.txt')
  t.ok(filename.search('walk-back/test/fixture/subdir/file.txt') > 0)
})

test('basic2', function (t) {
  t.plan(1)

  var filename = walkBack(__dirname + '/fixture', 'file.txt')
  t.ok(filename.search('walk-back/test/fixture/file.txt') > 0)
})

test('not found', function (t) {
  t.plan(1)

  var filename = walkBack(__dirname + '/fixture', 'adskjfhladfn')
  t.strictEqual(filename, null)
})

test('relative path', function (t) {
  t.plan(1)

  var filename = walkBack('.', 'test/fixture/subdir/file.txt')
  t.ok(filename && filename.search('walk-back/test/fixture/subdir/file.txt') > 0)
})

test('relative path 2', function (t) {
  t.plan(1)

  var filename = walkBack('./test/fixture/subdir', 'file.txt')
  t.ok(filename && filename.search('walk-back/test/fixture/subdir/file.txt') > 0)
})

test('startPath doesn\'t exist', function (t) {
  t.throws(function () {
    walkBack('slfnavnkln', 'file.txt')    
  })
  t.end()
})
