Skip to content

Commit

Permalink
Add tests for granularities with and w/o title in meta
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Sep 13, 2024
1 parent fab435c commit e74e844
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ describe('Cube Validation', () => {
{
const cube = newCube({
half_year: {
interval: '6 months'
interval: '6 months',
title: 'Half year intervals'
}
});

Expand Down Expand Up @@ -675,6 +676,7 @@ describe('Cube Validation', () => {
half_year: {
interval: '6 months',
offset: '4 weeks 5 days 6 hours',
title: 'Half year intervals title'
}
});

Expand Down Expand Up @@ -757,6 +759,7 @@ describe('Cube Validation', () => {
half_year: {
interval: '15 days',
offset: '1 hours 7 minutes 8 seconds',
title: 'Just title'
}
});

Expand Down Expand Up @@ -847,6 +850,7 @@ describe('Cube Validation', () => {
half_year: {
interval: '10 months',
origin: '2024-04',
title: 'Someone loves number 10'
}
});

Expand Down
10 changes: 8 additions & 2 deletions packages/cubejs-schema-compiler/test/unit/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,15 @@ describe('Schema Testing', () => {
expect(dg.granularities).toBeDefined();
expect(dg.granularities.length).toBeGreaterThan(0);

const gr = dg.granularities.find(g => g.name === 'half_year');
// Granularity defined with title
let gr = dg.granularities.find(g => g.name === 'half_year');
expect(gr).toBeDefined();
expect(gr.title).toBe('Half Year');
expect(gr.title).toBe('6 month intervals');

// // Granularity defined without title -> titlize()
gr = dg.granularities.find(g => g.name === 'half_year_by_1st_june');
expect(gr).toBeDefined();
expect(gr.title).toBe('Half Year By1 St June');
});

it('join types', async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/cubejs-schema-compiler/test/unit/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ export function createCubeSchemaWithCustomGranularities(name: string): string {
granularities: {
half_year: {
interval: '6 months',
title: '6 month intervals'
},
half_year_by_1st_april: {
title: 'Half year from Apr to Oct',
interval: '6 months',
offset: '3 months'
},
Expand Down
2 changes: 2 additions & 0 deletions packages/cubejs-schema-compiler/test/unit/yaml-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,12 @@ describe('Yaml Schema Testing', () => {
granularities:
- name: six_months
interval: 6 months
title: 6 month intervals
- name: three_months_offset
interval: 3 months
offset: 2 weeks
- name: fiscal_year_1st_april
title: Fiscal year by Apr
interval: 1 year
origin: >
2024-04-01
Expand Down

0 comments on commit e74e844

Please sign in to comment.