The Webfeed Flutter package for Appeto SDK.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

77 linhas
3.0 KiB

  1. import 'dart:core';
  2. import 'dart:io';
  3. import 'package:test/test.dart';
  4. import 'package:webfeed/webfeed.dart';
  5. void main() {
  6. test("parsing Invalid.xml", () {
  7. var xmlString = new File("test/xml/Invalid.xml").readAsStringSync();
  8. try {
  9. new RssFeed.parse(xmlString);
  10. fail("Should throw Argument Error");
  11. } on ArgumentError {}
  12. });
  13. test("parsing RSS.xml", () {
  14. var xmlString = new File("test/xml/RSS.xml").readAsStringSync();
  15. var feed = new RssFeed.parse(xmlString);
  16. expect(feed.title, "News - Foo bar News");
  17. expect(feed.description, "Foo bar News and Updates feed provided by Foo bar, Inc.");
  18. expect(feed.link, "https://foo.bar.news/");
  19. expect(feed.language, "en-US");
  20. expect(feed.lastBuildDate, "Mon, 26 Mar 2018 14:00:00 PDT");
  21. expect(feed.generator, "Custom");
  22. expect(feed.copyright, "Copyright 2018, Foo bar Inc.");
  23. expect(feed.docs, "https://foo.bar.news/docs");
  24. expect(feed.managingEditor, "alice@foo.bar.news");
  25. expect(feed.rating, "The PICS rating of the feed");
  26. expect(feed.webMaster, "webmaster@foo.bar.news");
  27. expect(feed.ttl, 60);
  28. expect(feed.image.title, "Foo bar News");
  29. expect(feed.image.url, "https://foo.bar.news/logo.gif");
  30. expect(feed.image.link, "https://foo.bar.news/");
  31. expect(feed.cloud.domain, "radio.foo.bar.news");
  32. expect(feed.cloud.port, "80");
  33. expect(feed.cloud.path, "/RPC2");
  34. expect(feed.cloud.registerProcedure, "foo.bar.rssPleaseNotify");
  35. expect(feed.cloud.protocol, "xml-rpc");
  36. expect(feed.categories.length, 2);
  37. expect(feed.categories[0].domain, null);
  38. expect(feed.categories[0].value, "Ipsum");
  39. expect(feed.categories[1].domain, "news");
  40. expect(feed.categories[1].value, "Lorem Ipsum");
  41. expect(feed.skipDays.length, 3);
  42. expect(feed.skipDays.contains("Monday"), true);
  43. expect(feed.skipDays.contains("Tuesday"), true);
  44. expect(feed.skipDays.contains("Sunday"), true);
  45. expect(feed.skipHours.length, 5);
  46. expect(feed.skipHours.contains(0), true);
  47. expect(feed.skipHours.contains(1), true);
  48. expect(feed.skipHours.contains(2), true);
  49. expect(feed.skipHours.contains(3), true);
  50. expect(feed.skipHours.contains(4), true);
  51. expect(feed.items.length, 2);
  52. expect(feed.items.first.title, "The standard Lorem Ipsum passage, used since the 1500s");
  53. expect(feed.items.first.description, "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
  54. expect(feed.items.first.link, "https://foo.bar.news/1");
  55. expect(feed.items.first.guid, "https://foo.bar.news/1?guid");
  56. expect(feed.items.first.pubDate, "Mon, 26 Mar 2018 14:00:00 PDT");
  57. expect(feed.items.first.categories.first.domain, "news");
  58. expect(feed.items.first.categories.first.value, "Lorem");
  59. expect(feed.items.first.author, "alice@foo.bar.news");
  60. expect(feed.items.first.source.url, "https://foo.bar.news/1?source");
  61. expect(feed.items.first.source.value, "Foo Bar");
  62. expect(feed.items.first.comments, "https://foo.bar.news/1/comments");
  63. });
  64. }