halkyon/packages/halkyon_base_server/test/unit/offered_ways_test.dart

32 lines
1 KiB
Dart
Raw Permalink Normal View History

import 'package:halkyon_base_server/base.dart';
import 'package:test/test.dart';
// SIGN_IN_WAYS (ADR 0020, 1): the ways in an operator offers.
void main() {
test('unset or empty, every way whose keys are there', () {
expect(offeredWaysFrom(null), isNull);
expect(offeredWaysFrom(''), isNull);
expect(offeredWaysFrom(' '), isNull);
});
test('names one way or both, by commas or spaces, whatever their case', () {
expect(offeredWaysFrom('simplelogin'), {OfferedWay.simpleLogin});
expect(offeredWaysFrom('password'), {OfferedWay.password});
expect(offeredWaysFrom('password, SimpleLogin'), {
OfferedWay.password,
OfferedWay.simpleLogin,
});
expect(offeredWaysFrom('simplelogin password'), hasLength(2));
});
test('refuses a way it does not know, so the server stops as it starts', () {
for (final value in ['github', 'simplelogin,email', 'passwords']) {
expect(
() => offeredWaysFrom(value),
throwsA(isA<StateError>()),
reason: value,
);
}
});
}