Skip to content

Commit

Permalink
Adjust search tests to current behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
BobdenOs committed Aug 5, 2024
1 parent c5f2de8 commit 635eaf7
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/scenarios/bookshop/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe.skip('Bookshop - Search', () => {
// ad-hoc search expression
Books['@cds.search.authorsAddress'] = true

let res = await SELECT.from(Books).columns('author.name as author', 'title').search('1 Main Street, Bradford')
let res = await SELECT.from(Books).columns('author.name as author', 'title').search('"1 Main Street, Bradford"')
// author name in res[0] must match "Emily Brontë"
expect(res.length).to.be.eq(1)
expect(res[0].author).to.be.eq('Emily Brontë')
Expand All @@ -91,12 +91,34 @@ describe.skip('Bookshop - Search', () => {
Books['@cds.search.author'] = true
Authors['@cds.search.address'] = true // address is a calculated element

let res = await SELECT.from(Books).columns('author.name as author', 'title').search('1 Main Street, Bradford')
let res = await SELECT.from(Books).columns('author.name as author', 'title').search('"1 Main Street, Bradford"')
// author name in res[0] must match "Emily Brontë"
expect(res.length).to.be.eq(1)
expect(res[0].author).to.be.eq('Emily Brontë')
})

test('Search escaped character in search literal', async () => {
const { Books } = cds.entities
const { Authors } = cds.entities
// ad-hoc search expression
Books['@cds.search.author'] = true
Authors['@cds.search.address'] = true // address is a calculated element

let res = await SELECT.from(Books).columns('author.name as author', 'title').search('"\\"\\\\"')
expect(res.length).to.be.eq(0)
})

test('Search improperly escaped character in search literal', async () => {
const { Books } = cds.entities
const { Authors } = cds.entities
// ad-hoc search expression
Books['@cds.search.author'] = true
Authors['@cds.search.address'] = true // address is a calculated element

let res = await SELECT.from(Books).columns('author.name as author', 'title').search('"\\q"')
expect(res.length).to.be.eq(0)
})

test('search on result of subselect', async () => {
const res = await cds.run(
SELECT.from(SELECT.from({ ref: ['sap.capire.bookshop.Books'] }).columns('title'))
Expand Down

0 comments on commit 635eaf7

Please sign in to comment.