ArtDecoCard.purs 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.Page.WorkExperiences (WorkExperiencesPage(..))
  12. import LinkedIn.Profile.WorkExperience (WorkExperience(..))
  13. import LinkedIn.Profile.WorkExperience as PWE
  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, detachFromString, fromDetachedToUI, 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
  34. (NonEmptyList (NonEmpty
  35. (ArtDecoPvsEntitySubComponent (Just (
  36. DetachedElement {
  37. classes: Nil,
  38. 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!",
  39. id: Nothing,
  40. tag: "SPAN"
  41. }))) Nil))),
  42. header: (ArtDecoCenterHeader {
  43. bold: (DetachedElement {
  44. classes: Nil,
  45. content: "Founder",
  46. id: Nothing,
  47. tag: "SPAN" }
  48. ), light: (Just (NonEmptyList (
  49. NonEmpty (
  50. DetachedElement {
  51. classes: ("pvs-entity__caption-wrapper" : Nil),
  52. content: "juin 2017 - aujourd’hui · 6 ans 7 mois",
  53. id: Nothing,
  54. tag: "SPAN"
  55. }) ((DetachedElement {
  56. classes: Nil,
  57. content: "Palo Alto, California, United States",
  58. id: Nothing,
  59. tag: "SPAN"
  60. }) : Nil)))),
  61. normal: (Just (DetachedElement {
  62. classes: Nil,
  63. content: "DeepLearning.AI",
  64. id: Nothing,
  65. tag: "SPAN" }))
  66. }) }),
  67. side: unit
  68. })
  69. }
  70. let
  71. jobOffer = (PWE.fromUI <=< fromDetachedToUI) head
  72. jobOffer `shouldEqual` Right (WorkExperience {
  73. company: Just "DeepLearning.AI",
  74. contractType: Nothing,
  75. 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!",
  76. duration: Just (YearsMonth 6 7),
  77. position: "Founder",
  78. timeSpan: Just (TimeSpanToToday (toMonthYear' June 2017))
  79. })