The Webfeed Flutter package for Appeto SDK.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.9 KiB

  1. import 'dart:io';
  2. import 'dart:core';
  3. import 'package:test/test.dart';
  4. import 'package:webfeedclient/domain/rss_feed.dart';
  5. import 'package:xml/xml.dart' as xml;
  6. void main() {
  7. test("parsing Invalid.xml", () {
  8. var xmlString = new File("test/xml/Invalid.xml").readAsStringSync();
  9. var doc = xml.parse(xmlString);
  10. try {
  11. new RssFeed.parse(doc);
  12. fail("Should throw Argument Error");
  13. } on ArgumentError {}
  14. });
  15. test("parsing RSS.xml", () {
  16. var xmlString = new File("test/xml/RSS.xml").readAsStringSync();
  17. var doc = xml.parse(xmlString);
  18. var feed = new RssFeed.parse(doc);
  19. expect(feed.title, "News - Foo bar News");
  20. expect(feed.description, "Foo bar News and Updates feed provided by Foo bar, Inc.");
  21. expect(feed.link, "https://foo.bar.news/");
  22. expect(feed.language, "en-US");
  23. expect(feed.lastBuildDate, "Mon, 26 Mar 2018 14:00:00 PDT");
  24. expect(feed.generator, "Custom");
  25. expect(feed.copyright, "Copyright 2018, Foo bar Inc.");
  26. expect(feed.image.title, "Foo bar News");
  27. expect(feed.image.url, "https://foo.bar.news/logo.gif");
  28. expect(feed.image.link, "https://foo.bar.news/");
  29. expect(feed.categories.length, 2);
  30. expect(feed.categories[0].domain, null);
  31. expect(feed.categories[0].value, "Ipsum");
  32. expect(feed.categories[1].domain, "news");
  33. expect(feed.categories[1].value, "Lorem Ipsum");
  34. expect(feed.items.length, 2);
  35. expect(feed.items.first.title, "The standard Lorem Ipsum passage, used since the 1500s");
  36. expect(feed.items.first.description, "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
  37. expect(feed.items.first.link, "https://foo.bar.news/1");
  38. expect(feed.items.first.guid, "https://foo.bar.news/1?guid");
  39. expect(feed.items.first.pubDate, "Mon, 26 Mar 2018 14:00:00 PDT");
  40. expect(feed.items.first.categories.first.domain, "news");
  41. expect(feed.items.first.categories.first.value, "Lorem");
  42. });
  43. }