@@ -4,7 +4,7 @@ import path from "node:path";
44
55import { transformFileSync } from "@babel/core" ;
66
7- import { plugin , type PluginOptions } from "./plugin.js" ;
7+ import { plugin , findNodeAddonForBindings , type PluginOptions } from "./plugin.js" ;
88import { setupTempDirectory } from "../test-utils.js" ;
99
1010describe ( "plugin" , ( ) => {
@@ -112,3 +112,31 @@ describe("plugin", () => {
112112 } ;
113113 } ) ;
114114} ) ;
115+
116+ describe ( "findNodeAddonForBindings()" , ( ) => {
117+ it ( "should look for addons in common paths" , ( context ) => {
118+ // Arrange
119+ const expectedPaths = {
120+ "addon_1" : "addon_1.node" ,
121+ "addon_2" : "build/Release/addon_2.node" ,
122+ "addon_3" : "build/Debug/addon_3.node" ,
123+ "addon_4" : "build/addon_4.node" ,
124+ "addon_5" : "out/Release/addon_5.node" ,
125+ "addon_6" : "out/Debug/addon_6.node" ,
126+ "addon_7" : "Release/addon_7.node" ,
127+ "addon_8" : "Debug/addon_8.node" ,
128+ } ;
129+ const tempDirectoryPath = setupTempDirectory ( context ,
130+ Object . fromEntries (
131+ Object . values ( expectedPaths )
132+ . map ( ( p ) => [ p , "// This is supposed to be a binary file" ] )
133+ )
134+ ) ;
135+ // Act & Assert
136+ Object . entries ( expectedPaths ) . forEach ( ( [ name , relPath ] ) => {
137+ const expectedPath = path . join ( tempDirectoryPath , relPath ) ;
138+ const actualPath = findNodeAddonForBindings ( name , tempDirectoryPath ) ;
139+ assert . equal ( actualPath , expectedPath ) ;
140+ } ) ;
141+ } ) ;
142+ } ) ;
0 commit comments