The Webfeed Flutter package for Appeto SDK.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

90 rader
3.3 KiB

  1. import 'dart:io';
  2. import 'dart:core';
  3. import 'package:test/test.dart';
  4. import 'package:webfeed/domain/atom_feed.dart';
  5. void main() {
  6. test("parsing Invalid.xml", () {
  7. var xmlString = new File("test/xml/Invalid.xml").readAsStringSync();
  8. try {
  9. new AtomFeed.parse(xmlString);
  10. fail("Should throw Argument Error");
  11. } on ArgumentError {}
  12. });
  13. test("parsing Atom.xml", () {
  14. var xmlString = new File("test/xml/Atom.xml").readAsStringSync();
  15. var feed = new AtomFeed.parse(xmlString);
  16. expect(feed.id, "foo-bar-id");
  17. expect(feed.title, "Foo bar news");
  18. expect(feed.updated, "2018-04-06T13:02:46Z");
  19. expect(feed.links.length, 2);
  20. expect(feed.links.first.rel, "foo");
  21. expect(feed.links.first.type, "text/html");
  22. expect(feed.links.first.hreflang, "en");
  23. expect(feed.links.first.href, "http://foo.bar.news/");
  24. expect(feed.links.first.title, "Foo bar news html");
  25. expect(feed.links.first.length, 1000);
  26. expect(feed.authors.length, 2);
  27. expect(feed.authors.first.name, "Alice");
  28. expect(feed.authors.first.uri, "http://foo.bar.news/people/alice");
  29. expect(feed.authors.first.email, "alice@foo.bar.news");
  30. expect(feed.contributors.length, 2);
  31. expect(feed.contributors.first.name, "Charlie");
  32. expect(feed.contributors.first.uri, "http://foo.bar.news/people/charlie");
  33. expect(feed.contributors.first.email, "charlie@foo.bar.news");
  34. expect(feed.categories.length, 2);
  35. expect(feed.categories.first.term, "foo category");
  36. expect(feed.categories.first.scheme, "this-is-foo-scheme");
  37. expect(feed.categories.first.label, "this is foo label");
  38. expect(feed.generator.uri, "http://foo.bar.news/generator");
  39. expect(feed.generator.version, "1.0");
  40. expect(feed.generator.value, "Foo bar generator");
  41. expect(feed.icon, "http://foo.bar.news/icon.png");
  42. expect(feed.logo, "http://foo.bar.news/logo.png");
  43. expect(feed.subtitle, "This is subtitle");
  44. expect(feed.items.length, 2);
  45. var item = feed.items.first;
  46. expect(item.id, "foo-bar-entry-id-1");
  47. expect(item.title, "Foo bar item 1");
  48. expect(item.updated, "2018-04-06T13:02:47Z");
  49. expect(item.authors.length, 2);
  50. expect(item.authors.first.name, "Ellie");
  51. expect(item.authors.first.uri, "http://foo.bar.news/people/ellie");
  52. expect(item.authors.first.email, "ellie@foo.bar.news");
  53. expect(item.links.length, 2);
  54. expect(item.links.first.rel, "foo entry");
  55. expect(item.links.first.type, "text/html");
  56. expect(item.links.first.hreflang, "en");
  57. expect(item.links.first.href, "http://foo.bar.news/entry");
  58. expect(item.links.first.title, "Foo bar news html");
  59. expect(item.links.first.length, 1000);
  60. expect(item.categories.length, 2);
  61. expect(item.categories.first.term, "foo entry category");
  62. expect(item.categories.first.scheme, "this-is-foo-entry-scheme");
  63. expect(item.categories.first.label, "this is foo entry label");
  64. expect(item.contributors.length, 2);
  65. expect(item.contributors.first.name, "Gin");
  66. expect(item.contributors.first.uri, "http://foo.bar.news/people/gin");
  67. expect(item.contributors.first.email, "gin@foo.bar.news");
  68. expect(item.published, "2018-04-06T13:02:49Z");
  69. expect(item.summary, "This is summary 1");
  70. expect(item.content, "This is content 1");
  71. expect(item.rights, "This is rights 1");
  72. });
  73. }