Added test for cds.localized:false
This commit is contained in:
12
test/localized-data.cds
Normal file
12
test/localized-data.cds
Normal file
@@ -0,0 +1,12 @@
|
||||
using { CatalogService, sap.capire.bookshop as my } from '@capire/bookshop';
|
||||
using from '@capire/common';
|
||||
|
||||
extend service CatalogService with {
|
||||
@cds.localized:false
|
||||
entity BooksSans as projection on my.Books {
|
||||
*, //> non-localized defaults, e.g. title
|
||||
key ID,
|
||||
texts.title as localized_title,
|
||||
texts.locale
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
describe('Localized Data', () => {
|
||||
const { GET, expect } = require('./capire').launch('bookshop')
|
||||
const { GET, expect } = require('./capire').launch('cds serve',__dirname+'/localized-data.cds')
|
||||
|
||||
it('serves localized $metadata documents', async () => {
|
||||
const { data } = await GET`/browse/$metadata?sap-language=de`
|
||||
@@ -66,9 +66,22 @@ describe('Localized Data', () => {
|
||||
name: 'Edgar Allen Poe',
|
||||
books: [
|
||||
{ title: 'The Raven', currency: { name: 'US-Dollar', symbol: '$' } },
|
||||
{ title: 'Eleonora', currency: { name: 'US-Dollar', symbol: '$' } },
|
||||
{ title: 'Eleonora', currency: { name: 'US-Dollar', symbol: '$' } },
|
||||
],
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('supports @cds.localized:false', async ()=>{
|
||||
const { data } = await GET(`/browse/BooksSans?&$select=title,localized_title&$expand=currency&$filter=locale eq 'de' or locale eq null`, {
|
||||
headers: { 'Accept-Language': 'de' },
|
||||
})
|
||||
expect(data.value).to.containSubset([
|
||||
{ title: 'Wuthering Heights', localized_title: 'Sturmhöhe', currency: { name: 'British Pound' } },
|
||||
{ title: 'Jane Eyre', currency: { name: 'British Pound' } },
|
||||
{ title: 'The Raven', currency: { name: 'US Dollar' } },
|
||||
{ title: 'Eleonora', currency: { name: 'US Dollar' } },
|
||||
{ title: 'Catweazle', currency: { name: 'Euro' } },
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user