Added test for cds.localized:false

This commit is contained in:
Daniel
2020-04-07 01:46:20 +02:00
parent 083266b11d
commit 1b338e450c
4 changed files with 29 additions and 4 deletions

12
test/localized-data.cds Normal file
View 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
};
}

View File

@@ -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' } },
])
})
})