Blob Blame History Raw
commit 8002138264f3837786c8b5ace7d4f16c8b8eb0e6
Author: Tom Hughes <tom@compton.nu>
Date:   Thu Aug 1 19:07:12 2019 +0100

    Do a proper three way compare when sorting

diff --git a/tests/walk_path-sorter.test.js b/tests/walk_path-sorter.test.js
index 48c5795..6504604 100644
--- a/tests/walk_path-sorter.test.js
+++ b/tests/walk_path-sorter.test.js
@@ -5,6 +5,12 @@ var test = require('./_test')
 var klaw = require('../')
 var fixtures = require('./fixtures_path-sorter')
 
+var stringCompare = function (a, b) {
+  if (a < b) return -1;
+  else if (a > b) return 1;
+  else return 0;
+};
+
 test('should sort in reverse order [z -> a]', function (t, testDir) {
   fixtures.forEach(function (f) {
     f = path.join(testDir, f)
@@ -14,7 +20,7 @@ test('should sort in reverse order [z -> a]', function (t, testDir) {
   })
 
   var items = []
-  var pathSorter = function (a, b) { return b > a }
+  var pathSorter = function (a, b) { return stringCompare(b, a) }
   klaw(testDir, { pathSorter: pathSorter })
     .on('data', function (item) {
       items.push(item.path)
@@ -41,7 +47,7 @@ test('should sort in order [a -> z]', function (t, testDir) {
   })
 
   var items = []
-  var pathSorter = function (a, b) { return a > b }
+  var pathSorter = function (a, b) { return stringCompare(a, b) }
   klaw(testDir, { pathSorter: pathSorter })
     .on('data', function (item) {
       items.push(item.path)