mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 07:16:01 +00:00
perspective display test WIP
This commit is contained in:
88
packages/datalib/src/tests/PerspectiveDisplay.test.ts
Normal file
88
packages/datalib/src/tests/PerspectiveDisplay.test.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { TableInfo } from 'dbgate-types';
|
||||
import { PerspectiveDisplay } from '../PerspectiveDisplay';
|
||||
import { PerspectiveTableNode } from '../PerspectiveTreeNode';
|
||||
import { chinookDbInfo } from './chinookDbInfo';
|
||||
import { createPerspectiveConfig } from '../PerspectiveConfig';
|
||||
import artistDataFlat from './artistDataFlat';
|
||||
import artistDataAlbum from './artistDataAlbum';
|
||||
import artistDataAlbumTrack from './artistDataAlbumTrack';
|
||||
|
||||
test('test flat view', () => {
|
||||
const artistTable = chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
||||
const root = new PerspectiveTableNode(artistTable, chinookDbInfo, createPerspectiveConfig(), null, null, null, null);
|
||||
const display = new PerspectiveDisplay(root, artistDataFlat);
|
||||
|
||||
console.log(display.rows);
|
||||
expect(display.rows.length).toEqual(5);
|
||||
expect(display.rows[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
rowData: ['AC/DC'],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('test one level nesting', () => {
|
||||
const artistTable = chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
||||
const root = new PerspectiveTableNode(
|
||||
artistTable,
|
||||
chinookDbInfo,
|
||||
{ ...createPerspectiveConfig(), checkedColumns: ['Artist.Album'] },
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
const display = new PerspectiveDisplay(root, artistDataAlbum);
|
||||
|
||||
console.log(display.rows);
|
||||
expect(display.rows.length).toEqual(7);
|
||||
expect(display.rows[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
rowData: ['AC/DC', 'For Those About To Rock We Salute You'],
|
||||
rowSpans: [2, 1],
|
||||
rowCellSkips: [false, false],
|
||||
})
|
||||
);
|
||||
expect(display.rows[1]).toEqual(
|
||||
expect.objectContaining({
|
||||
rowData: [undefined, 'Let There Be Rock'],
|
||||
rowSpans: [1, 1],
|
||||
rowCellSkips: [true, false],
|
||||
})
|
||||
);
|
||||
expect(display.rows[5]).toEqual(
|
||||
expect.objectContaining({
|
||||
rowData: ['Alanis Morissette', 'Jagged Little Pill'],
|
||||
rowSpans: [1, 1],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test('test two level nesting', () => {
|
||||
const artistTable = chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
||||
const root = new PerspectiveTableNode(
|
||||
artistTable,
|
||||
chinookDbInfo,
|
||||
{ ...createPerspectiveConfig(), checkedColumns: ['Artist.Album', 'Artist.Album.Track'] },
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
const display = new PerspectiveDisplay(root, artistDataAlbumTrack);
|
||||
|
||||
console.log(display.rows);
|
||||
expect(display.rows.length).toEqual(9);
|
||||
// expect(display.rows[0]).toEqual(
|
||||
// expect.objectContaining({
|
||||
// rowData: ['AC/DC', 'For Those About To Rock We Salute You'],
|
||||
// rowSpans: [2, 1],
|
||||
// })
|
||||
// );
|
||||
// expect(display.rows[5]).toEqual(
|
||||
// expect.objectContaining({
|
||||
// rowData: ['Alanis Morissette', 'Jagged Little Pill'],
|
||||
// rowSpans: [1, 1],
|
||||
// })
|
||||
// );
|
||||
});
|
||||
55
packages/datalib/src/tests/artistDataAlbum.ts
Normal file
55
packages/datalib/src/tests/artistDataAlbum.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
export default [
|
||||
{
|
||||
"ArtistId": 1,
|
||||
"Name": "AC/DC",
|
||||
"Album": [
|
||||
{
|
||||
"Title": "For Those About To Rock We Salute You",
|
||||
"ArtistId": 1
|
||||
},
|
||||
{
|
||||
"Title": "Let There Be Rock",
|
||||
"ArtistId": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ArtistId": 2,
|
||||
"Name": "Accept",
|
||||
"Album": [
|
||||
{
|
||||
"Title": "Balls to the Wall",
|
||||
"ArtistId": 2
|
||||
},
|
||||
{
|
||||
"Title": "Restless and Wild",
|
||||
"ArtistId": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ArtistId": 3,
|
||||
"Name": "Aerosmith",
|
||||
"Album": [
|
||||
{
|
||||
"Title": "Big Ones",
|
||||
"ArtistId": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ArtistId": 4,
|
||||
"Name": "Alanis Morissette",
|
||||
"Album": [
|
||||
{
|
||||
"Title": "Jagged Little Pill",
|
||||
"ArtistId": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"incompleteRowsIndicator": [
|
||||
"Artist"
|
||||
]
|
||||
}
|
||||
]
|
||||
78
packages/datalib/src/tests/artistDataAlbumTrack.ts
Normal file
78
packages/datalib/src/tests/artistDataAlbumTrack.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
export default [
|
||||
{
|
||||
ArtistId: 1,
|
||||
Name: 'AC/DC',
|
||||
Album: [
|
||||
{
|
||||
Title: 'For Those About To Rock We Salute You',
|
||||
AlbumId: 1,
|
||||
ArtistId: 1,
|
||||
Track: [
|
||||
{
|
||||
Name: 'For Those About To Rock (We Salute You)',
|
||||
AlbumId: 1,
|
||||
},
|
||||
{
|
||||
Name: 'Put The Finger On You',
|
||||
AlbumId: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
Title: 'Let There Be Rock',
|
||||
AlbumId: 4,
|
||||
ArtistId: 1,
|
||||
Track: [
|
||||
{
|
||||
Name: 'Go Down',
|
||||
AlbumId: 4,
|
||||
},
|
||||
{
|
||||
Name: 'Dog Eat Dog',
|
||||
AlbumId: 4,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
ArtistId: 2,
|
||||
Name: 'Accept',
|
||||
Album: [
|
||||
{
|
||||
Title: 'Balls to the Wall',
|
||||
AlbumId: 2,
|
||||
ArtistId: 2,
|
||||
Track: [
|
||||
{
|
||||
Name: 'Balls to the Wall',
|
||||
AlbumId: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
Title: 'Restless and Wild',
|
||||
AlbumId: 3,
|
||||
ArtistId: 2,
|
||||
Track: [
|
||||
{
|
||||
Name: 'Fast As a Shark',
|
||||
AlbumId: 3,
|
||||
},
|
||||
{
|
||||
Name: 'Restless and Wild',
|
||||
AlbumId: 3,
|
||||
},
|
||||
{
|
||||
Name: 'Princess of the Dawn',
|
||||
AlbumId: 3,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
incompleteRowsIndicator: ['Artist'],
|
||||
},
|
||||
];
|
||||
21
packages/datalib/src/tests/artistDataFlat.ts
Normal file
21
packages/datalib/src/tests/artistDataFlat.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export default [
|
||||
{
|
||||
ArtistId: 1,
|
||||
Name: 'AC/DC',
|
||||
},
|
||||
{
|
||||
ArtistId: 2,
|
||||
Name: 'Accept',
|
||||
},
|
||||
{
|
||||
ArtistId: 3,
|
||||
Name: 'Aerosmith',
|
||||
},
|
||||
{
|
||||
ArtistId: 4,
|
||||
Name: 'Alanis Morissette',
|
||||
},
|
||||
{
|
||||
incompleteRowsIndicator: ['Artist'],
|
||||
},
|
||||
];
|
||||
1777
packages/datalib/src/tests/chinookDbInfo.ts
Normal file
1777
packages/datalib/src/tests/chinookDbInfo.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user