feat: update tests

feat: update tests

feat: update tests
This commit is contained in:
2023-05-30 16:12:00 +02:00
parent d6d4f6e5c4
commit 0d60b8bfad
87 changed files with 1021 additions and 823 deletions

View File

@@ -12,46 +12,22 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {readdirSync, statSync} from 'fs';
import path from 'path';
import {MapAggTest} from './mapping-model/map-agg-test.js';
import {MapAggTestOptions} from './mapping-model/map-agg-test-options.js';
import {MapAggTest} from './mapping-model/map-agg-test';
import {MapAggTestOptions} from './mapping-model/map-agg-test-options';
import {expandPathToFilesSync} from './common';
describe('ES Mapping Gen', async () => {
const magAppInstance = new MapAggTest('mappings');
/**
* Expand a path to a list of all files deeply contained in it
*/
// eslint-disable-next-line unicorn/consistent-function-scoping
function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
const fullPath = path.resolve(sourcePath);
const directory = statSync(fullPath);
return directory.isDirectory()
? // eslint-disable-next-line unicorn/prefer-spread
([] as string[]).concat(
...readdirSync(fullPath).map(fragment =>
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
),
)
: [fullPath].filter(accept);
}
for (const file of expandPathToFilesSync('./test/mapping-model/mappings/', file =>
file.endsWith('mapping-test.ts'),
)) {
try {
// eslint-disable-next-line unicorn/no-await-expression-member
const test = (await import(file))['testConfig'] as MapAggTestOptions;
// eslint-disable-next-line unicorn/no-await-expression-member
const test = (await import(file))['testConfig'] as MapAggTestOptions;
it(test.testName, function () {
magAppInstance.testInterfaceAgainstPath(test);
});
} catch (error) {
console.error('UNHANDLED REJECTION', (error as any).stack);
process.exit(1);
}
it(test.testName, function () {
magAppInstance.testInterfaceAgainstPath(test);
});
}
})
.timeout(20_000)