mirror of
https://github.com/Sea-Haven-Industries/sh-mcp.git
synced 2026-09-30 07:43:17 +00:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
|
|
import { describe, it, expect } from 'vitest';
|
||
|
|
|
||
|
|
import {
|
||
|
|
computeMembershipDiff,
|
||
|
|
managedGroups,
|
||
|
|
normalizeEmail,
|
||
|
|
MANAGED_GROUP_NAMES,
|
||
|
|
} from '../src/groups.js';
|
||
|
|
|
||
|
|
describe('computeMembershipDiff', () => {
|
||
|
|
it('adds missing and removes extra, case-insensitively', () => {
|
||
|
|
const diff = computeMembershipDiff(
|
||
|
|
['Adam@seahavenind.com', 'old@seahavenind.com'],
|
||
|
|
['adam@seahavenind.com', 'new@seahavenind.com'],
|
||
|
|
);
|
||
|
|
expect(diff.toAdd).toEqual(['new@seahavenind.com']);
|
||
|
|
expect(diff.toRemove).toEqual(['old@seahavenind.com']);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('no-ops when membership already matches (ignoring case/whitespace)', () => {
|
||
|
|
const diff = computeMembershipDiff([' A@x.com '], ['a@x.com']);
|
||
|
|
expect(diff.toAdd).toEqual([]);
|
||
|
|
expect(diff.toRemove).toEqual([]);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('managedGroups', () => {
|
||
|
|
it('maps each Cognito group to its Google address on the given domain', () => {
|
||
|
|
const g = managedGroups('example.com');
|
||
|
|
expect(g.map((x) => x.cognito)).toEqual([...MANAGED_GROUP_NAMES]);
|
||
|
|
expect(g[0]).toEqual({ cognito: 'sh-mcp-ops', googleEmail: 'sh-mcp-ops@example.com' });
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('normalizeEmail', () => {
|
||
|
|
it('lowercases and trims', () => {
|
||
|
|
expect(normalizeEmail(' Foo@Bar.COM ')).toBe('foo@bar.com');
|
||
|
|
});
|
||
|
|
});
|