Skip to content

Commit fbd2bf0

Browse files
committed
test
1 parent 19f081a commit fbd2bf0

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cubes:
2+
- name: orders
3+
sql: SELECT * FROM orders
4+
5+
measures:
6+
- name: count
7+
sql: id
8+
type: count
9+
dimensions:
10+
- name: id
11+
sql: id
12+
type: number
13+
primary_key: true
14+
15+
- name: number
16+
sql: number
17+
type: number
18+
19+
- name: currency
20+
type: switch
21+
values:
22+
- USD
23+
- EUR
24+
- GBP
25+
26+
- name: status
27+
sql: status
28+
type: string
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
4+
import { CubeToMetaTransformer } from 'src/compiler/CubeToMetaTransformer';
5+
import { prepareYamlCompiler } from './PrepareCompiler';
6+
7+
describe('Switch Dimension', () => {
8+
it('Switch dimension meta type', async () => {
9+
const modelContent = fs.readFileSync(
10+
path.join(process.cwd(), '/test/unit/fixtures/switch-dimension.yml'),
11+
'utf8'
12+
);
13+
const prepared = prepareYamlCompiler(modelContent);
14+
const { metaTransformer } = prepared;
15+
const { compiler } = prepared;
16+
await compiler.compile();
17+
18+
const cube = metaTransformer.cubes[0];
19+
const numberDim = cube.config.dimensions.find((d) => d.name === 'orders.number');
20+
const statusDim = cube.config.dimensions.find((d) => d.name === 'orders.status');
21+
const currencyDim = cube.config.dimensions.find((d) => d.name === 'orders.currency');
22+
23+
expect(numberDim.type).toBe('number');
24+
expect(statusDim.type).toBe('string');
25+
expect(currencyDim.type).toBe('string');
26+
});
27+
});

0 commit comments

Comments
 (0)