Skip to content

Commit da81af7

Browse files
committed
fix test failure in windows
1 parent 3555a5f commit da81af7

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

packages/amazonq/test/unit/codewhisperer/util/supplemetalContextUtil.test.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ import assert from 'assert'
77
import * as FakeTimers from '@sinonjs/fake-timers'
88
import * as vscode from 'vscode'
99
import * as sinon from 'sinon'
10+
import * as os from 'os'
1011
import * as crossFile from 'aws-core-vscode/codewhisperer'
1112
import { TestFolder, assertTabCount, installFakeClock } from 'aws-core-vscode/test'
1213
import { CodeWhispererSupplementalContext, FeatureConfigProvider } from 'aws-core-vscode/codewhisperer'
1314
import { toTextEditor } from 'aws-core-vscode/test'
1415
import { LspController } from 'aws-core-vscode/amazonq'
1516

17+
const newLine = os.EOL
18+
1619
describe('supplementalContextUtil', function () {
1720
let testFolder: TestFolder
1821
let clock: FakeTimers.InstalledClock
@@ -116,51 +119,51 @@ describe('supplementalContextUtil', function () {
116119
it('truncateLineByLine should drop the last line if max length is greater than threshold', function () {
117120
const input =
118121
repeatString('a', 11) +
119-
'\n' +
122+
newLine +
120123
repeatString('b', 11) +
121-
'\n' +
124+
newLine +
122125
repeatString('c', 11) +
123-
'\n' +
126+
newLine +
124127
repeatString('d', 11) +
125-
'\n' +
128+
newLine +
126129
repeatString('e', 11)
127130

128131
assert.ok(input.length > 50)
129132
const actual = crossFile.truncateLineByLine(input, 50)
130133
assert.strictEqual(
131134
actual,
132135
repeatString('a', 11) +
133-
'\n' +
136+
newLine +
134137
repeatString('b', 11) +
135-
'\n' +
138+
newLine +
136139
repeatString('c', 11) +
137-
'\n' +
140+
newLine +
138141
repeatString('d', 11)
139142
)
140143

141-
const input2 = repeatString('b\n', 10)
144+
const input2 = repeatString(`b${newLine}`, 10)
142145
const actual2 = crossFile.truncateLineByLine(input2, 8)
143146
assert.strictEqual(actual2.length, 8)
144147
})
145148

146149
it('truncation context should make context length per item lte 10240 cap', function () {
147150
const chunkA: crossFile.CodeWhispererSupplementalContextItem = {
148-
content: repeatString('a\n', 4000),
151+
content: repeatString(`a${newLine}`, 4000),
149152
filePath: 'a.java',
150153
score: 0,
151154
}
152155
const chunkB: crossFile.CodeWhispererSupplementalContextItem = {
153-
content: repeatString('b\n', 6000),
156+
content: repeatString(`b${newLine}`, 6000),
154157
filePath: 'b.java',
155158
score: 1,
156159
}
157160
const chunkC: crossFile.CodeWhispererSupplementalContextItem = {
158-
content: repeatString('c\n', 1000),
161+
content: repeatString(`c${newLine}`, 1000),
159162
filePath: 'c.java',
160163
score: 2,
161164
}
162165
const chunkD: crossFile.CodeWhispererSupplementalContextItem = {
163-
content: repeatString('d\n', 1500),
166+
content: repeatString(`d${newLine}`, 1500),
164167
filePath: 'd.java',
165168
score: 3,
166169
}
@@ -260,7 +263,7 @@ describe('supplementalContextUtil', function () {
260263
})
261264

262265
it('should flip the value if negative max length is provided', function () {
263-
const input = 'aaaaa\nbbbbb'
266+
const input = `aaaaa${newLine}bbbbb`
264267
const actual = crossFile.truncateLineByLine(input, -6)
265268
const expected = crossFile.truncateLineByLine(input, 6)
266269
assert.strictEqual(actual, expected)

0 commit comments

Comments
 (0)