Skip to content

Commit 5033769

Browse files
committed
Rename linesToMergedStr in monitor-utils
Renames the method linesToMergedStr to joinLines in the serial monitor utils. This brings the name more in line with truncateLines. No functionality changes.
1 parent da8803e commit 5033769

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

arduino-ide-extension/src/browser/serial/monitor/monitor-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ export function truncateLines(
6868
return [lines, charCount];
6969
}
7070

71-
export function linesToMergedStr(lines: Line[]): string {
71+
export function joinLines(lines: Line[]): string {
7272
return lines.map((line: Line) => line.message).join('');
7373
}

arduino-ide-extension/src/browser/serial/monitor/serial-monitor-send-output.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Event } from '@theia/core/lib/common/event';
33
import { DisposableCollection } from '@theia/core/lib/common/disposable';
44
import { areEqual, FixedSizeList as List } from 'react-window';
55
import dateFormat from 'dateformat';
6-
import { messagesToLines, truncateLines, linesToMergedStr } from './monitor-utils';
6+
import { messagesToLines, truncateLines, joinLines } from './monitor-utils';
77
import { MonitorManagerProxyClient } from '../../../common/protocol';
88
import { MonitorModel } from '../../monitor-model';
99
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
@@ -76,7 +76,7 @@ export class SerialMonitorOutput extends React.Component<
7676
this.setState({ lines: [], charCount: 0 })
7777
),
7878
this.props.copyOutputEvent(() =>
79-
this.props.clipboardService.writeText(linesToMergedStr(this.state.lines))
79+
this.props.clipboardService.writeText(joinLines(this.state.lines))
8080
),
8181
this.props.monitorModel.onChange(({ property }) => {
8282
if (property === 'timestamp') {

arduino-ide-extension/src/test/browser/monitor-utils.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import {
33
messagesToLines,
44
truncateLines,
5-
linesToMergedStr,
5+
joinLines,
66
} from '../../browser/serial/monitor/monitor-utils';
77
import { Line } from '../../browser/serial/monitor/serial-monitor-send-output';
88
import { set, reset } from 'mockdate';
@@ -16,15 +16,15 @@ type TestLine = {
1616
charCount: number;
1717
maxCharacters?: number;
1818
};
19-
expectedMerged?: string;
19+
expectedJoined?: string;
2020
};
2121

2222
const date = new Date();
2323
const testLines: TestLine[] = [
2424
{
2525
messages: ['Hello'],
2626
expected: { lines: [{ message: 'Hello', lineLen: 5 }], charCount: 5 },
27-
expectedMerged: 'Hello',
27+
expectedJoined: 'Hello',
2828
},
2929
{
3030
messages: ['Hello', 'Dog!'],
@@ -39,7 +39,7 @@ const testLines: TestLine[] = [
3939
],
4040
charCount: 10,
4141
},
42-
expectedMerged: 'Hello\nDog!'
42+
expectedJoined: 'Hello\nDog!'
4343
},
4444
{
4545
messages: ['Dog!'],
@@ -71,7 +71,7 @@ const testLines: TestLine[] = [
7171
{ message: "You're a good boy!", lineLen: 8 },
7272
],
7373
},
74-
expectedMerged: "Hello Dog!\n Who's a good boy?\nYou're a good boy!",
74+
expectedJoined: "Hello Dog!\n Who's a good boy?\nYou're a good boy!",
7575
},
7676
{
7777
messages: ['boy?\n', "You're a good boy!"],
@@ -121,7 +121,7 @@ const testLines: TestLine[] = [
121121
{ message: 'Yo', lineLen: 2 },
122122
],
123123
},
124-
expectedMerged: "Hello Dog!\nWho's a good boy?\nYo",
124+
expectedJoined: "Hello Dog!\nWho's a good boy?\nYo",
125125
},
126126
];
127127

@@ -171,9 +171,9 @@ describe('Monitor Utils', () => {
171171
});
172172
expect(totalCharCount).to.equal(charCount);
173173
}
174-
if (testLine.expectedMerged) {
175-
const merged_str = linesToMergedStr(testLine.expected.lines);
176-
expect(merged_str).to.equal(testLine.expectedMerged);
174+
if (testLine.expectedJoined) {
175+
const joined_str = joinLines(testLine.expected.lines);
176+
expect(joined_str).to.equal(testLine.expectedJoined);
177177
}
178178
});
179179
});

0 commit comments

Comments
 (0)