Skip to content

Commit 8ea69c8

Browse files
committed
Using /tmp instead of current directory, and default number arguments to 0
1 parent 2d4e61e commit 8ea69c8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/bin/typescript-demo-lib.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import NumPair from '../lib/NumPair';
66
import { v4 as uuidv4 } from 'uuid';
77
import testWorkers from '../lib/workers/test-workers';
88
import testLevel from '../lib/test-level';
9-
import testUptNative from '../lib/test-utp-native';
9+
import testUtpNative from '../lib/test-utp-native';
1010

1111
async function main(argv = process.argv): Promise<number> {
1212
// Print out command-line arguments
@@ -22,15 +22,16 @@ async function main(argv = process.argv): Promise<number> {
2222
process.stdout.write(uuidv4() + '\n');
2323

2424
// Add the first two command-line args and print the result
25-
const nums = new NumPair(parseInt(argv[0]), parseInt(argv[1]));
25+
// default to using 0
26+
const nums = new NumPair(parseInt(argv[0] ?? 0), parseInt(argv[1] ?? 0));
2627
const sum = nums.num1 + nums.num2;
2728
process.stdout.write(nums.num1 + ' + ' + nums.num2 + ' = ' + sum + '\n');
2829

29-
// Testing native modules.
30-
const dir = argv[2] ?? '.';
30+
// Testing native modules
31+
const dir = argv[2] ?? '/tmp';
3132
await testLevel(dir);
3233
await testWorkers();
33-
await testUptNative();
34+
await testUtpNative();
3435

3536
process.exitCode = 0;
3637
return process.exitCode;

tests/bin/typescript-demo-lib.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ describe('main', () => {
3333
expect(tmpMockLog).toContain('[]\n');
3434
expect(tmpMockLog).toContain('new library\n');
3535
expect(tmpMockLog).toMatch(uuidRegex);
36-
expect(tmpMockLog).toContain('NaN + NaN = NaN\n');
36+
expect(tmpMockLog).toContain('0 + 0 = 0\n');
3737
mockLog.mockRestore();
38-
}, 20000);
38+
});
3939
test('adds 0 + 0', async () => {
4040
const mockLog = mockProcessStdout();
4141
await main(['', '', '0', '0', dataDir]);

0 commit comments

Comments
 (0)