calendar_api_url_generator_unittest.cc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "google_apis/calendar/calendar_api_url_generator.h"
  5. #include "base/time/time.h"
  6. #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
  7. namespace google_apis {
  8. namespace calendar {
  9. // Make sure the hard-coded urls are returned.
  10. TEST(CalendarApiUrlGeneratorTest, GetColorListUrl) {
  11. CalendarApiUrlGenerator url_generator_;
  12. EXPECT_EQ("https://www.googleapis.com/calendar/v3/colors",
  13. url_generator_.GetCalendarColorListUrl().spec());
  14. }
  15. TEST(CalendarApiUrlGeneratorTest, GetEventListUrl) {
  16. CalendarApiUrlGenerator url_generator_;
  17. base::Time start;
  18. EXPECT_TRUE(base::Time::FromString("13 Jun 2021 10:00 PST", &start));
  19. base::Time end;
  20. EXPECT_TRUE(base::Time::FromString("16 Jun 2021 10:00 PST", &end));
  21. EXPECT_EQ(
  22. "https://www.googleapis.com/calendar/v3/calendars/primary/"
  23. "events?timeMin=2021-06-13T18%3A00%3A00.000Z"
  24. "&timeMax=2021-06-16T18%3A00%3A00.000Z"
  25. "&singleEvents=true"
  26. "&maxAttendees=1",
  27. url_generator_
  28. .GetCalendarEventListUrl(start, end, /*single_events=*/true,
  29. /*max_attendees=*/1)
  30. .spec());
  31. }
  32. TEST(CalendarApiUrlGeneratorTest, GetEventListUrlWithDefaultMaxAttendees) {
  33. CalendarApiUrlGenerator url_generator_;
  34. base::Time start;
  35. EXPECT_TRUE(base::Time::FromString("13 Jun 2021 10:00 PST", &start));
  36. base::Time end;
  37. EXPECT_TRUE(base::Time::FromString("16 Jun 2021 10:00 PST", &end));
  38. EXPECT_EQ(
  39. "https://www.googleapis.com/calendar/v3/calendars/primary/"
  40. "events?timeMin=2021-06-13T18%3A00%3A00.000Z"
  41. "&timeMax=2021-06-16T18%3A00%3A00.000Z"
  42. "&singleEvents=true",
  43. url_generator_
  44. .GetCalendarEventListUrl(start, end, /*single_events=*/true,
  45. /*max_attendees=*/absl::nullopt)
  46. .spec());
  47. }
  48. } // namespace calendar
  49. } // namespace google_apis