Skip to content

Commit

Permalink
feat: can extract attribute key from FlatMap
Browse files Browse the repository at this point in the history
  • Loading branch information
sgulseth committed Feb 21, 2024
1 parent c1526c9 commit c5cd5cb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ function extractPropertyKey(node: ExprNode): string {
if (
node.type === 'Deref' ||
node.type === 'Map' ||
node.type === 'FlatMap' ||
node.type === 'Projection' ||
node.type === 'Slice' ||
node.type === 'Filter' ||
Expand Down
43 changes: 43 additions & 0 deletions tap-snapshots/test/parse.test.ts.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,49 @@ Object {
}
`

exports[`test/parse.test.ts TAP Expression parsing when extracting property keys can extract from flatmap > must match snapshot 1`] = `
Object {
"base": Object {
"type": "Everything",
},
"expr": Object {
"base": Object {
"type": "This",
},
"expr": Object {
"attributes": Array [
Object {
"name": "a",
"type": "ObjectAttributeValue",
"value": Object {
"base": Object {
"base": Object {
"name": "a",
"type": "AccessAttribute",
},
"type": "ArrayCoerce",
},
"expr": Object {
"base": Object {
"base": Object {
"type": "This",
},
"type": "Deref",
},
"type": "ArrayCoerce",
},
"type": "FlatMap",
},
},
],
"type": "Object",
},
"type": "Projection",
},
"type": "Map",
}
`

exports[`test/parse.test.ts TAP Expression parsing when extracting property keys can extract from group > must match snapshot 1`] = `
Object {
"base": Object {
Expand Down
4 changes: 4 additions & 0 deletions test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ t.test('Expression parsing', async (t) => {
t.test('can extract from group', async (t) => {
t.matchSnapshot(parse('*{(id)}'))
})

t.test('can extract from flatmap', async (t) => {
t.matchSnapshot(parse('*{a[]->[]}'))
})
})

t.test('when parsing operators', async (t) => {
Expand Down

0 comments on commit c5cd5cb

Please sign in to comment.