halkyon/halkyon_learn_flutter/test/feature/studyset/model/license_test.dart

26 lines
1.2 KiB
Dart
Raw Normal View History

import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_learn_flutter/src/feature/studyset/model/license.dart';
void main() {
test('a licence is kept in one spelling: known ones as known, Creative '
'Commons by its identifier, anything else as typed', () {
expect(canonicalLicense('Cc By 4.0'), 'CC-BY-4.0');
expect(canonicalLicense('cc_by_sa'), 'CC-BY-SA-4.0');
expect(canonicalLicense('public domain'), 'CC0-1.0');
expect(canonicalLicense('mit'), 'MIT');
expect(canonicalLicense('arr'), 'All Rights Reserved');
expect(canonicalLicense('cc by-nc-sa 3.0 us'), 'CC-BY-NC-SA-3.0-US');
expect(canonicalLicense(' My own terms '), 'My own terms');
expect(canonicalLicense(' '), isNull);
expect(canonicalLicense(null), isNull);
});
test('an older or ported Creative Commons licence has a current version; '
'a current one, or another licence, none', () {
expect(newerCreativeCommons('CC-BY-NC-SA-3.0-US'), 'CC-BY-NC-SA-4.0');
expect(newerCreativeCommons('CC-BY-2.0'), 'CC-BY-4.0');
expect(newerCreativeCommons('CC-BY-SA-4.0'), isNull);
expect(newerCreativeCommons('CC0-1.0'), isNull);
expect(newerCreativeCommons('MIT'), isNull);
});
}