ArtDecoCard.purs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. module Test.ArtDecoCard where
  2. import Prelude
  3. import Data.Date (Month(..))
  4. import Data.Either (Either(..))
  5. import Data.List (List(..), (:))
  6. import Data.List.NonEmpty (NonEmptyList(..))
  7. import Data.List.NonEmpty as NEL
  8. import Data.Maybe (Maybe(..))
  9. import Data.NonEmpty (NonEmpty(..))
  10. import LinkedIn.DetachedNode (DetachedNode(..))
  11. import LinkedIn.Output.Types (Output(..))
  12. import LinkedIn.Page.WorkExperiences (WorkExperiencesPage(..))
  13. import LinkedIn.Profile.WorkExperience (WorkExperience(..))
  14. import LinkedIn.Profile.WorkExperience as PWE
  15. import LinkedIn.UI.Basic.Types (Duration(..), TimeSpan(..))
  16. import LinkedIn.UI.Components.ArtDeco (ArtDecoCenter(..), ArtDecoCenterContent(..), ArtDecoCenterHeader(..), ArtDecoPvsEntity(..), ArtDecoPvsEntitySubComponent(..))
  17. import LinkedIn.UI.Components.ArtDecoCard (ArtDecoCardElement(..))
  18. import Test.Spec (Spec, describe, it)
  19. import Test.Spec.Assertions (fail, shouldEqual)
  20. import Test.Utils (detachFromFile, fromDetachedToUI, getOutputFromFile, toMonthYear')
  21. import Type.Proxy (Proxy(..))
  22. artDecoCardsSpec :: Spec Unit
  23. artDecoCardsSpec = do
  24. describe "Art deco cards parsing" do
  25. it "works" do
  26. cards <- detachFromFile (Proxy :: Proxy WorkExperiencesPage) "test/examples/andrew_ng_experiences.html"
  27. case cards of
  28. Left _ -> fail "Detach operation failed"
  29. Right (WorkExperiencesPage c) -> do
  30. let head = NEL.head c
  31. head `shouldEqual` ArtDecoCardElement {
  32. pvs_entity: (ArtDecoPvsEntity {
  33. center: (ArtDecoCenter {
  34. content: (ArtDecoCenterContent
  35. (NonEmptyList (NonEmpty
  36. (ArtDecoPvsEntitySubComponent (
  37. DetachedElement {
  38. classes: Nil,
  39. 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!",
  40. id: Nothing,
  41. tag: "SPAN"
  42. })) Nil))),
  43. header: (ArtDecoCenterHeader {
  44. bold: (DetachedElement {
  45. classes: Nil,
  46. content: "Founder",
  47. id: Nothing,
  48. tag: "SPAN" }
  49. ), light: (Just (NonEmptyList (
  50. NonEmpty (
  51. DetachedElement {
  52. classes: ("pvs-entity__caption-wrapper" : Nil),
  53. content: "juin 2017 - aujourd’hui · 6 ans 7 mois",
  54. id: Nothing,
  55. tag: "SPAN"
  56. }) ((DetachedElement {
  57. classes: Nil,
  58. content: "Palo Alto, California, United States",
  59. id: Nothing,
  60. tag: "SPAN"
  61. }) : Nil)))),
  62. normal: (Just (DetachedElement {
  63. classes: Nil,
  64. content: "DeepLearning.AI",
  65. id: Nothing,
  66. tag: "SPAN" }))
  67. }) }),
  68. side: unit
  69. })
  70. }
  71. let
  72. jobOffer = (PWE.fromUI <=< fromDetachedToUI) head
  73. jobOffer `shouldEqual` Right (WorkExperience {
  74. company: Just "DeepLearning.AI",
  75. contractType: Nothing,
  76. 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!",
  77. duration: Just (YearsMonth 6 7),
  78. position: "Founder",
  79. timeSpan: Just (TimeSpanToToday (toMonthYear' June 2017))
  80. })
  81. it "reads the work experience" do
  82. wxpPage <- getOutputFromFile (Proxy :: Proxy WorkExperiencesPage) "test/examples/andrew_ng_experiences.html"
  83. case wxpPage of
  84. Left _ -> fail "Conversion to UI failed"
  85. Right (OutWorkExperiences weps) -> do
  86. let head = NEL.head weps
  87. head `shouldEqual` WorkExperience {
  88. company: Just "DeepLearning.AI",
  89. contractType: Nothing,
  90. 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!",
  91. duration: Just (YearsMonth 6 7),
  92. position: "Founder",
  93. timeSpan: Just (TimeSpanToToday (toMonthYear' June 2017))
  94. }
  95. Right _ -> fail "Conversion to UI failed"