Skip to content

Commit 8ccebe7

Browse files
committed
test: improve artifacts tests and fix a small bug
1 parent d1d7308 commit 8ccebe7

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/transform/artifacts/artifacts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ export function extractCurrentScope(
130130
}
131131

132132
export function addArtifactMarkings(code: string, filePath: string, config?: FlytrapConfig) {
133-
code = code.replaceAll('\t', ' ')
134133
const functionOrCallIdsAndLocations: ArtifactMarking[] = []
135134
const parseCodeResult = parseCode(code, filePath, getParseConfig(config?.babel?.parserOptions))
136135

test/artifacts.test.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ type ArtifactMarkingsTest = {
178178
callDef?: string
179179
}
180180

181-
function codeToArtifactMarkingsTest(fixture: string): ArtifactMarkingsTest {
181+
function codeToArtifactMarkingsTest(fixture: string): Omit<ArtifactMarkingsTest, 'fixture'> {
182182
const artifactMarkingsResult = addArtifactMarkings(fixture, '/file.js')
183183

184184
if (artifactMarkingsResult.err) {
@@ -192,7 +192,6 @@ function codeToArtifactMarkingsTest(fixture: string): ArtifactMarkingsTest {
192192
const argumentsMarking = markings.find((m) => m.type === 'arguments')
193193
const paramsMarking = markings.find((m) => m.type === 'params')
194194
return {
195-
fixture,
196195
...(functionMarking && {
197196
functionDef: fixture.substring(functionMarking.startIndex, functionMarking.endIndex)
198197
}),
@@ -215,17 +214,27 @@ const artifactMarkingsFixtures: Record<string, ArtifactMarkingsTest[]> = {
215214
callDef: 'console.log',
216215
argumentsDef: '(a)'
217216
},
217+
{
218+
fixture: 'console.log(a, b)',
219+
callDef: 'console.log',
220+
argumentsDef: '(a, b)'
221+
},
218222
{
219223
fixture: 'console.log()',
220224
callDef: 'console.log',
221225
argumentsDef: '()'
222226
},
223227
// random spacing
224228
{
225-
fixture: 'console.log (a) ',
229+
fixture: 'console.log (a)',
226230
callDef: 'console.log',
227231
argumentsDef: '(a)'
228232
},
233+
{
234+
fixture: 'console.log (a, b)',
235+
callDef: 'console.log',
236+
argumentsDef: '(a, b)'
237+
},
229238
{
230239
fixture: 'console.log () ',
231240
callDef: 'console.log',
@@ -323,11 +332,12 @@ const artifactMarkingsFixtures: Record<string, ArtifactMarkingsTest[]> = {
323332
]
324333
}
325334

326-
describe.skip('artifact markings new @todo add back', () => {
335+
describe('artifact markings new', () => {
327336
for (const [suiteName, artifactTests] of Object.entries(artifactMarkingsFixtures)) {
328337
it(suiteName, () => {
329338
for (let i = 0; i < artifactTests.length; i++) {
330-
expect(codeToArtifactMarkingsTest(artifactTests[i].fixture)).toEqual(artifactTests[i])
339+
const { fixture, ...testWithoutFixture } = artifactTests[i]
340+
expect(codeToArtifactMarkingsTest(artifactTests[i].fixture)).toEqual(testWithoutFixture)
331341
}
332342
})
333343
}

test/transform.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ it('doesnt transform reserved words', () => {
579579
})
580580

581581
// @todo: add this test back
582-
it.skip('transforms .vue files', async () => {
582+
it('transforms .vue files', async () => {
583583
const fixture = `
584584
<script setup>
585585
function foo() {

0 commit comments

Comments
 (0)