ArtDecoCard.purs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. type TestCase a = { detached ∷ a DetachedNode , filePath ∷ String , output ∷ WorkExperience }
  22. -- Original URL : https://www.linkedin.com/in/andrewyng/details/experience
  23. andrewNgWorkExperience ∷ TestCase ArtDecoCardElement
  24. andrewNgWorkExperience = {
  25. filePath: "test/examples/andrew_ng_experiences.html",
  26. detached: ArtDecoCardElement {
  27. pvs_entity: (ArtDecoPvsEntity {
  28. center: (ArtDecoCenter {
  29. content: (ArtDecoCenterContent (NonEmptyList (NonEmpty (ArtDecoPvsEntitySubComponent (
  30. 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"}))
  31. Nil
  32. ))),
  33. header: (ArtDecoCenterHeader {
  34. bold: (DetachedElement {classes: Nil, content: "Founder", id: Nothing, tag: "SPAN" }),
  35. light:
  36. DetachedElement {classes: ("pvs-entity__caption-wrapper" : Nil), content: "juin 2017 - aujourd’hui · 6 ans 9 mois", id: Nothing,tag: "SPAN"}
  37. : DetachedElement {classes: Nil, content: "Palo Alto, California, United States", id: Nothing,tag: "SPAN"}
  38. : Nil,
  39. normal: (Just (DetachedElement {classes: Nil, content: "DeepLearning.AI", id: Nothing, tag: "SPAN" }))
  40. })
  41. }),
  42. side: unit
  43. })
  44. },
  45. output: WorkExperience {
  46. company: Just "DeepLearning.AI",
  47. contractType: Nothing,
  48. 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!",
  49. duration: Just (YearsMonth 6 9),
  50. position: "Founder",
  51. timeSpan: Just (TimeSpanToToday (toMonthYear' June 2017))
  52. }
  53. }
  54. artDecoCardsSpec :: Spec Unit
  55. artDecoCardsSpec = do
  56. describe "Art deco cards parsing" do
  57. it "works" do
  58. cards <- detachFromFile (Proxy :: Proxy WorkExperiencesPage) andrewNgWorkExperience.filePath
  59. case cards of
  60. Left _ -> fail "Detach operation failed"
  61. Right (WorkExperiencesPage c) -> do
  62. let head = NEL.head c
  63. head `shouldEqual` andrewNgWorkExperience.detached
  64. it "reads the work experience" do
  65. wxpPage <- getOutputFromFile (Proxy :: Proxy WorkExperiencesPage) andrewNgWorkExperience.filePath
  66. case wxpPage of
  67. Right (OutWorkExperiences weps) -> do
  68. let head = NEL.head weps
  69. head `shouldEqual` andrewNgWorkExperience.output
  70. _ -> fail "Test failed"