import 'package:np_api/np_api.dart'; import 'package:test/test.dart'; void main() { group("NcAlbumParser", () { test("no album", _noAlbum); test("empty", _empty); test("basic", _basic); test("collaborative", _collaborative); }); } Future _noAlbum() async { const xml = """ /remote.php/dav/photos/admin/albums/ HTTP/1.1 404 Not Found """; final results = await NcAlbumParser().parse(xml); expect( results, [ const NcAlbum( href: "/remote.php/dav/photos/admin/albums/", lastPhoto: null, nbItems: null, location: null, dateRange: null, collaborators: [], ), ], ); } Future _empty() async { const xml = """ /remote.php/dav/photos/admin/albums/ HTTP/1.1 404 Not Found /remote.php/dav/photos/admin/albums/test/ -1 0 {"start":null,"end":null} HTTP/1.1 200 OK """; final results = await NcAlbumParser().parse(xml); expect( results, [ const NcAlbum( href: "/remote.php/dav/photos/admin/albums/", lastPhoto: null, nbItems: null, location: null, dateRange: null, collaborators: [], ), const NcAlbum( href: "/remote.php/dav/photos/admin/albums/test/", lastPhoto: -1, nbItems: 0, location: null, dateRange: { "start": null, "end": null, }, collaborators: [], ), ], ); } Future _basic() async { const xml = """ /remote.php/dav/photos/admin/albums/ HTTP/1.1 404 Not Found /remote.php/dav/photos/admin/albums/test/ 1 1 {"start":1577934245,"end":1580702706} HTTP/1.1 200 OK """; final results = await NcAlbumParser().parse(xml); expect( results, [ const NcAlbum( href: "/remote.php/dav/photos/admin/albums/", lastPhoto: null, nbItems: null, location: null, dateRange: null, collaborators: [], ), const NcAlbum( href: "/remote.php/dav/photos/admin/albums/test/", lastPhoto: 1, nbItems: 1, location: null, dateRange: { "start": 1577934245, "end": 1580702706, }, collaborators: [], ), ], ); } Future _collaborative() async { const xml = """ /remote.php/dav/photos/admin/albums/ HTTP/1.1 404 Not Found /remote.php/dav/photos/admin/albums/test/ 1 1 {"start":1577934245,"end":1580702706} user2 0 HTTP/1.1 200 OK """; final results = await NcAlbumParser().parse(xml); expect( results, [ const NcAlbum( href: "/remote.php/dav/photos/admin/albums/", lastPhoto: null, nbItems: null, location: null, dateRange: null, collaborators: [], ), const NcAlbum( href: "/remote.php/dav/photos/admin/albums/test/", lastPhoto: 1, nbItems: 1, location: null, dateRange: { "start": 1577934245, "end": 1580702706, }, collaborators: [ NcAlbumCollaborator( id: "user2", label: "User2", type: 0, ), ], ), ], ); }