add test for root level
authorJustin Wind <justin.wind+git@gmail.com>
Sat, 4 May 2024 20:34:21 +0000 (13:34 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Sat, 4 May 2024 20:34:21 +0000 (13:34 -0700)
test/lib/file-scope.js

index b8fc12386ab8710d5c30a7957a53153bc2ec9c2c..44749110cbadb3886ee7e3b4c371cb81d28cd326 100644 (file)
@@ -276,6 +276,17 @@ describe('File Scope', function () {
       assert.strictEqual(result, 'deep:method');
     });
 
+    it('handles package root file', function () {
+      filepath = '/path/to/package/server.js';
+      fs.statSync.restore();
+      sinon.stub(fs, 'statSync')
+        .throws(noentError)
+        .onCall(0).returns() // packageBase found
+      ;
+      const result = fileScope(filepath)(method);
+      assert.strictEqual(result, 'server:method');
+    });
+
   }); // fileScope