Skip to content

Commit

Permalink
test: fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Sep 1, 2022
1 parent 52fd986 commit b336d47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/findReplace/testcases/convertRequiresToImports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ASTPath } from 'jscodeshift'
import { NodePath } from '../../../src/types'

export const input = `
const foo = require('foo')
Expand All @@ -8,7 +8,7 @@ const {glom, qlx} = require('foo')
`
export const find = `const $1 = require('$a')`
export const where = {
$1: (path: ASTPath): boolean => path.node.type === 'Identifier',
$1: (path: NodePath): boolean => path.node.type === 'Identifier',
}

export const expectedFind = [
Expand Down
9 changes: 6 additions & 3 deletions test/findReplace/testcases/replaceFunction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import j, { ASTNode } from 'jscodeshift'
import { ParsePattern } from '../../../src/Astx'
import { Match } from '../../../src/find'
import { Node } from '../../../src/types'

export const input = `
1 + 2
Expand All @@ -9,8 +10,10 @@ const foo = bar

export const find = `$a + $b`

export const replace = ({ captures: { $a, $b } }: Match<any>): ASTNode =>
j.template.expression`${$b} + ${$a}`
export const replace = (
{ captures: { $a, $b } = {} }: Match,
parse: ParsePattern
): Node | Node[] => parse`${$b} + ${$a}`

export const expectedReplace = `
2 + 1
Expand Down
6 changes: 3 additions & 3 deletions test/findReplace/testcases/where.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ASTPath } from 'jscodeshift'
import { NodePath } from '../../../src/types'

export const input = `
1 + 2
Expand All @@ -9,8 +9,8 @@ const foo = bar
export const find = `$a + $b`

export const where = {
$b: (path: ASTPath<any>): boolean =>
typeof path.node.value === 'number' && path.node.value < 4,
$b: (path: NodePath): boolean =>
typeof path.value.value === 'number' && path.value.value < 4,
}

export const expectedFind = [
Expand Down

0 comments on commit b336d47

Please sign in to comment.