mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-28 03:42:11 +00:00
fix: filter tags override inherited type tags
This commit is contained in:
@@ -13,59 +13,38 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {slow, suite, test, timeout} from '@testdeck/mocha';
|
||||
import {readdirSync, statSync} from 'fs';
|
||||
import path from 'path';
|
||||
import {MapAggTest} from './mapping-model/MapAggTest';
|
||||
import {aggArrayTest} from './mapping-model/aggregations/src/agg-array';
|
||||
import {aggNestedTest} from './mapping-model/aggregations/src/agg-nested';
|
||||
import {aggGlobalTest} from './mapping-model/aggregations/src/agg-global';
|
||||
import {aggGlobalNestedTest} from './mapping-model/aggregations/src/agg-global-nested';
|
||||
import {aggInheritedTest} from './mapping-model/aggregations/src/agg-inherited';
|
||||
import {aggInheritedGlobalTest} from './mapping-model/aggregations/src/agg-inherited-global';
|
||||
import {aggInheritedOverwrittenTest} from './mapping-model/aggregations/src/agg-inherited-overwritten';
|
||||
import {MapAggTestOptions} from './mapping-model/MapAggTestOptions';
|
||||
|
||||
process.on('unhandledRejection', (error: unknown) => {
|
||||
if (error instanceof Error) {
|
||||
void Logger.error('UNHANDLED REJECTION', error.stack);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
describe('ES Aggregation Gen', async () => {
|
||||
const magAppInstance = new MapAggTest('aggregations');
|
||||
|
||||
const magAppInstance = new MapAggTest('aggregations');
|
||||
/**
|
||||
* Expand a path to a list of all files deeply contained in it
|
||||
*/
|
||||
function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
|
||||
const fullPath = path.resolve(sourcePath);
|
||||
const directory = statSync(fullPath);
|
||||
|
||||
@suite(timeout(20000), slow(10000))
|
||||
export class AggregationsSpec {
|
||||
@test
|
||||
async 'Aggregation tag should propagate on arrays'() {
|
||||
magAppInstance.testInterfaceAgainstPath(aggArrayTest);
|
||||
return directory.isDirectory()
|
||||
? ([] as string[]).concat(...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
))
|
||||
: [fullPath].filter(accept);
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Should work on nested properties'() {
|
||||
magAppInstance.testInterfaceAgainstPath(aggNestedTest);
|
||||
}
|
||||
for (const file of expandPathToFilesSync('./test/mapping-model/aggregations/', file => file.endsWith('agg-test.ts'))) {
|
||||
try {
|
||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||
|
||||
@test
|
||||
async 'Global option should work'() {
|
||||
magAppInstance.testInterfaceAgainstPath(aggGlobalTest);
|
||||
it(test.testName, function () {
|
||||
magAppInstance.testInterfaceAgainstPath(test);
|
||||
});
|
||||
} catch (error) {
|
||||
await Logger.error('UNHANDLED REJECTION', error.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Global aggregations when nested'() {
|
||||
magAppInstance.testInterfaceAgainstPath(aggGlobalNestedTest);
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Inherited aggregations should work'() {
|
||||
magAppInstance.testInterfaceAgainstPath(aggInheritedTest);
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Inherited global aggregations should work'() {
|
||||
magAppInstance.testInterfaceAgainstPath(aggInheritedGlobalTest);
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Inherited aggregations should work when overwritten'() {
|
||||
magAppInstance.testInterfaceAgainstPath(aggInheritedOverwrittenTest);
|
||||
}
|
||||
}
|
||||
}).timeout(20_000).slow(10_000);
|
||||
|
||||
Reference in New Issue
Block a user