11import { vol } from "memfs" ;
2- import {
3- corePkg ,
4- fsRoot ,
5- nodecgPackageJson ,
6- nodecgPackageJsonStr ,
7- twitchChatPkg ,
8- validDevInstall ,
9- validProdInstall ,
10- } from "../test.util" ;
2+ import { corePkg , fsRoot , nodecgPackageJsonStr , twitchChatPkg , validDevInstall , validProdInstall } from "../test.util" ;
113import { SemVer } from "semver" ;
124import * as path from "path" ;
135import * as installation from "../../src/utils/installation" ;
@@ -56,29 +48,29 @@ describe("generateBundle", () => {
5648 test ( "should fail if bundle directory already contains files" , async ( ) => {
5749 // Create some file inside the directory in which the bundle would be generated.
5850 await vol . promises . writeFile ( packageJsonPath , "" ) ;
59- await expect ( generateBundle ( fsRoot , defaultOpts , validProdInstall ) ) . rejects . toThrow (
51+ await expect ( generateBundle ( defaultOpts , validProdInstall ) ) . rejects . toThrow (
6052 "already exists and contains files" ,
6153 ) ;
6254 } ) ;
6355
6456 test ( "should install dependencies" , async ( ) => {
6557 const installMock = jest . spyOn ( npm , "runNpmInstall" ) . mockResolvedValue ( ) ;
66- await generateBundle ( fsRoot , defaultOpts , validProdInstall ) ;
58+ await generateBundle ( defaultOpts , validProdInstall ) ;
6759
6860 expect ( installMock ) . toHaveBeenCalled ( ) ;
6961 expect ( installMock ) . toHaveBeenCalledWith ( defaultOpts . bundlePath , false ) ;
7062 } ) ;
7163
7264 test ( "should run build if typescript" , async ( ) => {
7365 const buildMock = jest . spyOn ( npm , "runNpmBuild" ) . mockClear ( ) . mockResolvedValue ( ) ;
74- await generateBundle ( fsRoot , defaultOpts , validProdInstall ) ;
66+ await generateBundle ( defaultOpts , validProdInstall ) ;
7567 expect ( buildMock ) . toHaveBeenCalledTimes ( 1 ) ;
7668 expect ( buildMock ) . toHaveBeenCalledWith ( defaultOpts . bundlePath ) ;
7769 } ) ;
7870
7971 test ( "should not run build if javascript" , async ( ) => {
8072 const buildMock = jest . spyOn ( npm , "runNpmBuild" ) . mockClear ( ) . mockResolvedValue ( ) ;
81- await generateBundle ( fsRoot , jsOpts , validProdInstall ) ;
73+ await generateBundle ( jsOpts , validProdInstall ) ;
8274 expect ( buildMock ) . toHaveBeenCalledTimes ( 0 ) ;
8375 } ) ;
8476} ) ;
@@ -87,7 +79,7 @@ describe("genPackageJson", () => {
8779 // We don't have a good type for a package.json and this is only testing code so this should be fine.
8880 // eslint-disable-next-line @typescript-eslint/no-explicit-any
8981 async function genPackageJSON ( opts : GenerationOptions = defaultOpts ) : Promise < any > {
90- await generateBundle ( fsRoot , opts , validProdInstall ) ;
82+ await generateBundle ( opts , validProdInstall ) ;
9183 const packageJsonStr = await vol . promises . readFile ( packageJsonPath ) ;
9284 if ( ! packageJsonStr ) throw new Error ( "package.json does not exist" ) ;
9385 return JSON . parse ( packageJsonStr . toString ( ) ) ;
@@ -112,12 +104,12 @@ describe("genPackageJson", () => {
112104 test ( "should have all required typing packages as dependency if typescript" , async ( ) => {
113105 const deps = ( await genPackageJSON ( defaultOpts ) ) [ "dependencies" ] ;
114106 const e = Object . entries ( deps ) ;
115- expect ( e ) . toEqual ( expect . arrayContaining ( [ [ "nodecg" , `^${ nodecgPackageJson . version } ` ] ] ) ) ;
116107 expect ( e ) . toEqual ( expect . arrayContaining ( [ [ twitchChatPkg . name , `^${ twitchChatPkg . version } ` ] ] ) ) ;
117108
118109 // These dependencies should always have the latest version which is fetched by the mocked getLatestPackageVersion
119110 expect ( e ) . toEqual ( expect . arrayContaining ( [ [ "typescript" , `^1.2.3` ] ] ) ) ;
120111 expect ( e ) . toEqual ( expect . arrayContaining ( [ [ "@types/node" , `^1.2.3` ] ] ) ) ;
112+ expect ( e ) . toEqual ( expect . arrayContaining ( [ [ "nodecg-types" , `^1.2.3` ] ] ) ) ;
121113 } ) ;
122114
123115 test ( "should have build scripts if typescript" , async ( ) => {
0 commit comments