forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextUtils.ts
More file actions
26 lines (21 loc) · 966 Bytes
/
textUtils.ts
File metadata and controls
26 lines (21 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { expect } from 'chai';
import { MarkedString } from 'vscode';
export function normalizeMarkedString(content: MarkedString): string {
return typeof content === 'string' ? content : content.value;
}
export function compareFiles(expectedContent: string, actualContent: string) {
const expectedLines = expectedContent.split(/\r?\n/);
const actualLines = actualContent.split(/\r?\n/);
for (let i = 0; i < Math.min(expectedLines.length, actualLines.length); i += 1) {
const e = expectedLines[i];
const a = actualLines[i];
expect(e, `Difference at line ${i}`).to.be.equal(a);
}
expect(actualLines.length,
expectedLines.length > actualLines.length
? 'Actual contains more lines than expected'
: 'Expected contains more lines than the actual'
).to.be.equal(expectedLines.length);
}