Files
GitJournal/test/md_yaml_doc_loader_test.dart
Vishesh Handa 657721adc6 Update dart-git and stop using the Result class
Instead we're going to move back to standard exceptions.

Using a custom Result class has created far far more problems
- The Stacktraces aren't always right
- Sometimes one forgets to check the Result error
- All other exception throwing code needing to be converted to Results
- Non idiomatic Dart code

I think it's better to just go back to exceptions. They have their
problems, but overall, I think it's a better approach.
2023-11-24 14:03:30 +01:00

48 lines
1.1 KiB
Dart

/*
* SPDX-FileCopyrightText: 2019-2021 Vishesh Handa <me@vhanda.in>
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import 'package:gitjournal/core/markdown/md_yaml_doc_loader.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
import 'package:universal_io/io.dart';
import 'lib.dart';
void main() {
setUpAll(gjSetupAllTests);
group('MdYamlDocLoader', () {
late Directory tempDir;
late String filePath;
var contents = """---
type: Journal
foo: bar
---
Alright.""";
setUpAll(() async {
tempDir = await Directory.systemTemp.createTemp('__doc_loader_test__');
filePath = p.join(tempDir.path, "doc0");
await File(filePath).writeAsString(contents);
});
tearDownAll(() async {
tempDir.deleteSync(recursive: true);
});
test('Should load one doc', () async {
var loader = MdYamlDocLoader();
var doc = await loader.loadDoc(filePath);
expect(doc.body, "Alright.");
expect(doc.props["type"], "Journal");
expect(doc.props["foo"], "bar");
expect(doc.props.length, 2);
});
});
}