ArtDecoCard.purs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. module Test.ArtDecoCard where
  2. import Prelude
  3. import Data.Date (Month(..))
  4. import Data.Either (Either(..), hush, isRight)
  5. import Data.List (List(..), (:))
  6. import Data.List.NonEmpty (NonEmptyList(..))
  7. import Data.List.NonEmpty as NEL
  8. import Data.Maybe (Maybe(..), fromJust)
  9. import Data.NonEmpty (NonEmpty(..))
  10. import Data.Traversable (traverse)
  11. import Effect (Effect)
  12. import LinkedIn.ArtDeco (ArtDecoCenter(..), ArtDecoCenterContent(..), ArtDecoCenterHeader(..), ArtDecoPvsEntity(..), ArtDecoPvsEntitySubComponent(..))
  13. import LinkedIn.ArtDecoCard (ArtDecoCardElement(..))
  14. import LinkedIn.DetachedNode (DetachedNode(..), toDetached)
  15. import LinkedIn.Page.WorkExperiences (WorkExperiencesPage(..))
  16. import LinkedIn.Page.WorkExperiences as PageWE
  17. import LinkedIn.Profile.WorkExperience (WorkExperience(..))
  18. import LinkedIn.Profile.WorkExperience as PWE
  19. import LinkedIn.QueryRunner (runQuery)
  20. import LinkedIn.UIElements.Types (Duration(..), TimeSpan(..))
  21. import Node.JsDom (jsDomFromFile)
  22. import Partial.Unsafe (unsafePartial)
  23. import Test.Assert (assert, assertEqual)
  24. import Test.Utils (toMonthYear')
  25. testArtDecoCards :: Effect Unit
  26. testArtDecoCards = do
  27. dom <- jsDomFromFile "test/examples/andrew_ng_experiences.html"
  28. wep <- runQuery $ PageWE.query dom
  29. assert $ isRight wep
  30. let
  31. WorkExperiencesPage cards = unsafePartial $ fromJust $ hush wep
  32. head = NEL.head cards
  33. headCard <- traverse toDetached head
  34. assertEqual {
  35. actual: headCard,
  36. expected:
  37. ArtDecoCardElement {
  38. pvs_entity: (ArtDecoPvsEntity {
  39. center: (ArtDecoCenter {
  40. content: (ArtDecoCenterContent
  41. (NonEmptyList (NonEmpty
  42. (ArtDecoPvsEntitySubComponent (Just (
  43. DetachedElement {
  44. classes: Nil,
  45. content: "DeepLearning.AI provides\ntechnical training on Generative AI, Machine Learning, Deep Learning,\nand other topics. We also offer a widely read newsletter, The Batch\n(thebatch.ai), that covers what matters in AI right now. Our courses are often created with industry-leading AI companies (AWS,\nGoogle, OpenAI, etc.), and we offer both short courses that can be\ncompleted in an hour, and longer courses and specializations hosted on\nCoursera that give you a solid foundation in some aspect of AI. These\ncourses are designed to offer hands-on practice with AI technologies,\nand you will gain practical, job-ready skills. Whether you are just starting out in AI or seeking to further an existing\ncareer, come see if we can help, at http://deeplearning.ai!",
  46. id: Nothing,
  47. tag: "SPAN"
  48. }))) Nil))),
  49. header: (ArtDecoCenterHeader {
  50. bold: (DetachedElement {
  51. classes: Nil,
  52. content: "Founder",
  53. id: Nothing,
  54. tag: "SPAN" }
  55. ), light: (Just (NonEmptyList (
  56. NonEmpty (
  57. DetachedElement {
  58. classes: ("pvs-entity__caption-wrapper" : Nil),
  59. content: "juin 2017 - aujourd’hui · 6 ans 7 mois",
  60. id: Nothing,
  61. tag: "SPAN"
  62. }) ((DetachedElement {
  63. classes: Nil,
  64. content: "Palo Alto, California, United States",
  65. id: Nothing,
  66. tag: "SPAN"
  67. }) : Nil)))),
  68. normal: (Just (DetachedElement {
  69. classes: Nil,
  70. content: "DeepLearning.AI",
  71. id: Nothing,
  72. tag: "SPAN" }))
  73. }) }),
  74. side: unit
  75. })
  76. }
  77. }
  78. assertEqual {
  79. actual: PWE.fromUI headCard,
  80. expected:
  81. Right (WorkExperience {
  82. company: Just "DeepLearning.AI",
  83. contractType: Nothing,
  84. description: Just "DeepLearning.AI provides\ntechnical training on Generative AI, Machine Learning, Deep Learning,\nand other topics. We also offer a widely read newsletter, The Batch\n(thebatch.ai), that covers what matters in AI right now. Our courses are often created with industry-leading AI companies (AWS,\nGoogle, OpenAI, etc.), and we offer both short courses that can be\ncompleted in an hour, and longer courses and specializations hosted on\nCoursera that give you a solid foundation in some aspect of AI. These\ncourses are designed to offer hands-on practice with AI technologies,\nand you will gain practical, job-ready skills. Whether you are just starting out in AI or seeking to further an existing\ncareer, come see if we can help, at http://deeplearning.ai!",
  85. duration: Just (YearsMonth 6 7),
  86. position: "Founder",
  87. timeSpan: Just (TimeSpanToToday (toMonthYear' June 2017))
  88. })
  89. }
  90. main :: Effect Unit
  91. main = do
  92. testArtDecoCards