feat: compact dataset descriptions

This commit is contained in:
Andrea Marco Sartori
2023-01-17 21:02:47 +10:00
parent 6982b02d48
commit 2bffd6a51e
4 changed files with 139 additions and 41 deletions

View File

@ -23,7 +23,7 @@ it('show the actual dataset of non-named datasets in their description', functio
], __FILE__));
expect($descriptions[0])->toBe('(1)');
expect($descriptions[1])->toBe('(array(2))');
expect($descriptions[1])->toBe('([2])');
});
it('show only the names of multiple named datasets in their description', function () {
@ -57,9 +57,9 @@ it('show the actual dataset of multiple non-named datasets in their description'
], __FILE__));
expect($descriptions[0])->toBe('(1) / (3)');
expect($descriptions[1])->toBe('(1) / (array(4))');
expect($descriptions[2])->toBe('(array(2)) / (3)');
expect($descriptions[3])->toBe('(array(2)) / (array(4))');
expect($descriptions[1])->toBe('(1) / ([4])');
expect($descriptions[2])->toBe('([2]) / (3)');
expect($descriptions[3])->toBe('([2]) / ([4])');
});
it('show the correct description for mixed named and not-named datasets', function () {
@ -76,6 +76,26 @@ it('show the correct description for mixed named and not-named datasets', functi
expect($descriptions[0])->toBe('data set "one" / (3)');
expect($descriptions[1])->toBe('data set "one" / data set "four"');
expect($descriptions[2])->toBe('(array(2)) / (3)');
expect($descriptions[3])->toBe('(array(2)) / data set "four"');
expect($descriptions[2])->toBe('([2]) / (3)');
expect($descriptions[3])->toBe('([2]) / data set "four"');
});
it('shows the correct description for long texts with newlines', function () {
$descriptions = array_keys(DatasetsRepository::resolve([
[
['some very \nlong text with \n newlines'],
],
], __FILE__));
expect($descriptions[0])->toBe('(\'some very long text with …wlines\')');
});
it('shows the correct description for arrays with many elements', function () {
$descriptions = array_keys(DatasetsRepository::resolve([
[
[[1, 2, 3, 4, 5]],
],
], __FILE__));
expect($descriptions[0])->toBe('([1, 2, 3, …])');
});