Skip to content

Commit d5205cb

Browse files
committed
add schema tests for joins as array/object
1 parent 47e353b commit d5205cb

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

packages/cubejs-schema-compiler/test/unit/__snapshots__/schema.test.ts.snap

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,46 @@ Array [
20912091
]
20922092
`;
20932093

2094+
exports[`Schema Testing join types (joins as array) 1`] = `
2095+
Array [
2096+
Object {
2097+
"name": "CubeB",
2098+
"relationship": "hasOne",
2099+
"sql": [Function],
2100+
},
2101+
Object {
2102+
"name": "CubeC",
2103+
"relationship": "hasMany",
2104+
"sql": [Function],
2105+
},
2106+
Object {
2107+
"name": "CubeD",
2108+
"relationship": "belongsTo",
2109+
"sql": [Function],
2110+
},
2111+
]
2112+
`;
2113+
2114+
exports[`Schema Testing join types (joins as object) 1`] = `
2115+
Array [
2116+
Object {
2117+
"name": "CubeB",
2118+
"relationship": "hasOne",
2119+
"sql": [Function],
2120+
},
2121+
Object {
2122+
"name": "CubeC",
2123+
"relationship": "hasMany",
2124+
"sql": [Function],
2125+
},
2126+
Object {
2127+
"name": "CubeD",
2128+
"relationship": "belongsTo",
2129+
"sql": [Function],
2130+
},
2131+
]
2132+
`;
2133+
20942134
exports[`Schema Testing join types 1`] = `
20952135
Array [
20962136
Object {

packages/cubejs-schema-compiler/test/unit/schema.test.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ describe('Schema Testing', () => {
416416
expect(gr.origin).toBe('2020-06-01 10:00:00');
417417
});
418418

419-
it('join types', async () => {
419+
it('join types (joins as object)', async () => {
420420
const { compiler, cubeEvaluator } = prepareJsCompiler([
421421
createCubeSchema({
422422
name: 'CubeA',
@@ -450,6 +450,43 @@ describe('Schema Testing', () => {
450450
expect(cubeEvaluator.cubeFromPath('CubeA').joins).toMatchSnapshot();
451451
});
452452

453+
it('join types (joins as array)', async () => {
454+
const { compiler, cubeEvaluator } = prepareJsCompiler([
455+
createCubeSchema({
456+
name: 'CubeA',
457+
joins: `[
458+
{
459+
name: 'CubeB',
460+
sql: \`SQL ON clause\`,
461+
relationship: 'one_to_one'
462+
},
463+
{
464+
name: 'CubeC',
465+
sql: \`SQL ON clause\`,
466+
relationship: 'one_to_many'
467+
},
468+
{
469+
name: 'CubeD',
470+
sql: \`SQL ON clause\`,
471+
relationship: 'many_to_one'
472+
},
473+
]`
474+
}),
475+
createCubeSchema({
476+
name: 'CubeB',
477+
}),
478+
createCubeSchema({
479+
name: 'CubeC',
480+
}),
481+
createCubeSchema({
482+
name: 'CubeD',
483+
}),
484+
]);
485+
await compiler.compile();
486+
487+
expect(cubeEvaluator.cubeFromPath('CubeA').joins).toMatchSnapshot();
488+
});
489+
453490
describe('Access Policies', () => {
454491
it('valid schema with accessPolicy', async () => {
455492
const { compiler } = prepareJsCompiler([

0 commit comments

Comments
 (0)