Skip to content

Commit 2eb2b11

Browse files
committed
test: remove the temporary file creation
TICKET: WP-5445
1 parent ee326a2 commit 2eb2b11

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

modules/express/test/unit/typedRoutes/signerMacaroon.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as assert from 'assert';
22
import * as sinon from 'sinon';
3-
import * as fs from 'fs';
4-
import { agent as supertest } from 'supertest';
3+
import * as request from 'supertest';
4+
import proxyquire from 'proxyquire';
55
import 'should';
66
import 'should-http';
77
import 'should-sinon';
@@ -10,29 +10,28 @@ import { BitGo } from 'bitgo';
1010
import { PostSignerMacaroon } from '../../../src/typedRoutes/api/v2/signerMacaroon';
1111
import { LndSignerClient } from '../../../src/lightning/lndSignerClient';
1212

13+
proxyquire.noPreserveCache();
14+
1315
describe('Signer Macaroon Typed Routes Tests', function () {
14-
let agent: ReturnType<typeof supertest>;
15-
const tempFilePath = '/tmp/test-lightning-signer.json';
16+
let agent: request.SuperAgentTest;
1617

1718
before(function () {
18-
// Create a temporary JSON file for lightning signer config
19-
fs.writeFileSync(tempFilePath, JSON.stringify({}));
20-
21-
const { app } = require('../../../src/expressApp');
22-
// Configure app with lightning signer enabled
23-
const config = {
24-
...require('../../../src/config').DefaultConfig,
25-
lightningSignerFileSystemPath: tempFilePath,
19+
const validLightningSignerConfigJSON = '{}';
20+
const { app } = proxyquire('../../../src/expressApp', {
21+
fs: {
22+
readFileSync: () => validLightningSignerConfigJSON,
23+
},
24+
});
25+
26+
const args: any = {
27+
debug: false,
28+
env: 'test',
29+
logfile: '/dev/null',
30+
lightningSignerFileSystemPath: '/mock/path/lightning-signer.json',
2631
};
27-
const testApp = app(config);
28-
agent = supertest(testApp);
29-
});
3032

31-
after(function () {
32-
// Clean up the temporary file
33-
if (fs.existsSync(tempFilePath)) {
34-
fs.unlinkSync(tempFilePath);
35-
}
33+
const testApp = app(args);
34+
agent = request.agent(testApp);
3635
});
3736

3837
afterEach(function () {

0 commit comments

Comments
 (0)