// SPDX-FileCopyrightText: 2026 TatuChat // // SPDX-License-Identifier: AGPL-3.0-or-later import 'package:flutter_test/flutter_test.dart'; import 'package:tatchat/utils/miniapp_meta.dart'; void main() { test('Parses a valid manifest from meta tags', () { const html = ''' '''; final meta = parseMiniAppMeta(html); expect(meta.id, 'myapp'); expect(meta.name, 'My App'); expect(meta.category, 'productivity'); expect(meta.description, 'Does things'); expect(meta.logo, 'data:image/png;base64,AAAA'); expect(meta.inChat, isTrue); }); test('Allows empty optional values and defaults inChat to false', () { const html = ''' '''; final meta = parseMiniAppMeta(html); expect(meta.id, 'empty'); expect(meta.name, 'Empty'); expect(meta.category, ''); expect(meta.description, ''); expect(meta.logo, ''); expect(meta.inChat, isFalse); }); test('Independent of attribute order and quoting style', () { final tags = extractMetaTags( '' "", ); expect(tags['mini-app-id'], 'x'); expect(tags['mini-app-name'], 'N'); }); test('Rejects documents missing required meta tags', () { expect(() => parseMiniAppMeta(''), throwsFormatException); const missingOptional = ''' '''; expect(() => parseMiniAppMeta(missingOptional), throwsFormatException); }); test('Rejects empty or missing id/name', () { const emptyId = ''' '''; expect(() => parseMiniAppMeta(emptyId), throwsFormatException); const emptyName = ''' '''; expect(() => parseMiniAppMeta(emptyName), throwsFormatException); }); }