Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposition for the tests about the 🔥 emoji #1

Open
alexphok opened this issue Jun 29, 2023 · 0 comments
Open

Proposition for the tests about the 🔥 emoji #1

alexphok opened this issue Jun 29, 2023 · 0 comments

Comments

@alexphok
Copy link

alexphok commented Jun 29, 2023

  it("should write a 🔥 emoji besides the title if the story has a score higher than 100", async () => {
      // Build
      const mockStoryIds = [1, 2];
      const mockStoryDetails = [
        { title: "Story 1", url: "http://example.com/story1", score: 100 },
        { title: "Story 2", url: "http://example.com/story2", score: 200 },
      ];

      // Mock the get function of axios to return the mockStoryIds response
      axiosSpy.mockResolvedValueOnce({ data: mockStoryIds });

      // Mock the get function of axios to return the mockStoryDetails responses
      mockStoryIds.forEach((id, index) => {
        axiosSpy.mockResolvedValueOnce({ data: mockStoryDetails[index] });
      });

      render(<App />);
      // Operate
      const storyTitle = await screen.findByText(/Story 2/i);
      // Check
      expect(storyTitle.textContent).toContain("🔥");
    });

    it("should not write a 🔥 emoji besides the title if the story has a score lower than 100", async () => {
      // Build
      const mockStoryIds = [1, 2];
      const mockStoryDetails = [
        { title: "Story 1", url: "http://example.com/story1", score: 100 },
        { title: "Story 2", url: "http://example.com/story2", score: 200 },
      ];

      // Mock the get function of axios to return the mockStoryIds response
      axiosSpy.mockResolvedValueOnce({ data: mockStoryIds });

      // Mock the get function of axios to return the mockStoryDetails responses
      mockStoryIds.forEach((id, index) => {
        axiosSpy.mockResolvedValueOnce({ data: mockStoryDetails[index] });
      });

      render(<App />);

      // Operate
      const storyTitle = await screen.findByText(/Story 1/i);
      // Check
      expect(storyTitle.textContent).not.toContain("🔥");
    });
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant