ArtDecoCard.purs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.UI.Basic.Types (Duration(..), TimeSpan(..))
  15. import LinkedIn.UI.Components.ArtDeco (ArtDecoCenter(..), ArtDecoCenterContent(..), ArtDecoCenterHeader(..), ArtDecoPvsEntity(..), ArtDecoPvsEntitySubComponent(..))
  16. import LinkedIn.UI.Components.ArtDecoCard (ArtDecoCardElement(..))
  17. import Test.Spec (Spec, describe, it)
  18. import Test.Spec.Assertions (fail, shouldEqual)
  19. import Test.Utils (detachFromFile, getOutputFromFile, toMonthYear')
  20. import Type.Proxy (Proxy(..))
  21. artDecoCardsSpec :: Spec Unit
  22. artDecoCardsSpec = do
  23. describe "Art deco cards parsing" do
  24. it "works" do
  25. cards <- detachFromFile (Proxy :: Proxy WorkExperiencesPage) "test/examples/andrew_ng_experiences.html"
  26. case cards of
  27. Left _ -> fail "Detach operation failed"
  28. Right (WorkExperiencesPage c) -> do
  29. let head = NEL.head c
  30. head `shouldEqual` ArtDecoCardElement {
  31. pvs_entity: (ArtDecoPvsEntity {
  32. center: (ArtDecoCenter {
  33. content: (ArtDecoCenterContent (NonEmptyList (NonEmpty (ArtDecoPvsEntitySubComponent (
  34. DetachedElement {classes: Nil, 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!", id: Nothing, tag: "SPAN"}))
  35. Nil
  36. ))),
  37. header: (ArtDecoCenterHeader {
  38. bold: (DetachedElement {classes: Nil, content: "Founder", id: Nothing, tag: "SPAN" }),
  39. light: (Just (NonEmptyList (NonEmpty (
  40. DetachedElement {classes: ("pvs-entity__caption-wrapper" : Nil), content: "juin 2017 - aujourd’hui · 6 ans 7 mois", id: Nothing,tag: "SPAN"})
  41. ((DetachedElement {classes: Nil, content: "Palo Alto, California, United States", id: Nothing,tag: "SPAN"}) : Nil)
  42. ))),
  43. normal: (Just (DetachedElement {classes: Nil, content: "DeepLearning.AI", id: Nothing, tag: "SPAN" }))
  44. })
  45. }),
  46. side: unit
  47. })
  48. }
  49. it "reads the work experience" do
  50. wxpPage <- getOutputFromFile (Proxy :: Proxy WorkExperiencesPage) "test/examples/andrew_ng_experiences.html"
  51. case wxpPage of
  52. Right (OutWorkExperiences weps) -> do
  53. let head = NEL.head weps
  54. head `shouldEqual` WorkExperience {
  55. company: Just "DeepLearning.AI",
  56. contractType: Nothing,
  57. 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!",
  58. duration: Just (YearsMonth 6 7),
  59. position: "Founder",
  60. timeSpan: Just (TimeSpanToToday (toMonthYear' June 2017))
  61. }
  62. _ -> fail "Test failed"