All files / blong-int-adapter/keycloak/test/test testKeycloakRealmFind.ts

100% Statements 19/19
100% Branches 4/4
100% Functions 2/2
100% Lines 19/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 201x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x  
import {handler} from '@feasibleone/blong';
import type Assert from 'node:assert';
 
export default handler(({lib: {group}, handler: {authRealmFind}}) => ({
    testKeycloakRealmFind: ({name = 'keycloak realm list'}: {name?: string}) =>
        group(name)([
            async function listRealms(assert: typeof Assert, {$meta}) {
                const result = await authRealmFind({}, $meta);
                assert.ok(Array.isArray(result), 'Realm list should return an array');
                assert.ok(
                    (result as unknown[]).length > 0,
                    'Realm list should contain at least the master realm',
                );
                const master = (result as {realm?: string}[]).find(r => r.realm === 'master');
                assert.ok(master, 'master realm should be present');
                return result;
            },
        ]),
}));