Skip to content

Commit

Permalink
docs: add examples for clock.install() followed by pauseAt()
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeIwaki committed Feb 2, 2025
1 parent ccc142a commit 2aacd2e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
9 changes: 9 additions & 0 deletions development/generate_api/example_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,15 @@ def example_e3bfa88ff84efbef1546730c2046e627141c6cd5f09c54dc2cf0e07cbb17c0b5(pag
page.clock.pause_at("2020-02-02")
end

# Clock#pause_at
def example_a455277e025b97b226ec675888cebfd13b06e296accc56892e5c4ed164cfc317(page:)
# Initialize clock with some time before the test time and let the page load
# naturally. `Date.now` will progress as the timers fire.
page.clock.install(Time.parse("2024-12-10T08:00:00Z"))
page.goto("http://localhost:3333")
page.clock.pause_at(Time.parse("2024-12-10T10:00:00Z"))
end

# Clock#set_fixed_time
def example_612285ca3970e44df82608ceff6f6b9ae471b0f7860b60916bbaefd327dd2ffd(page:)
page.clock.set_fixed_time(Time.now)
Expand Down
11 changes: 0 additions & 11 deletions development/unimplemented_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ Excample codes in API documentation is replaces with the methods defined in deve
The examples listed below is not yet implemented, and documentation shows Python code.


### example_a455277e025b97b226ec675888cebfd13b06e296accc56892e5c4ed164cfc317 (Clock#pause_at)

```
# Initialize clock with some time before the test time and let the page load
# naturally. `Date.now` will progress as the timers fire.
page.clock.install(time=datetime.datetime(2024, 12, 10, 8, 0, 0))
page.goto("http://localhost:3333")
page.clock.pause_at(datetime.datetime(2024, 12, 10, 10, 0, 0))
```

### example_7778d4f89215025560ecd192d60831f898331a0f339607a657c038207951e473 (LocatorAssertions#to_have_class)

```
Expand Down
7 changes: 3 additions & 4 deletions documentation/docs/api/clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,12 @@ page.clock.pause_at("2020-02-02")

For best results, install the clock before navigating the page and set it to a time slightly before the intended test time. This ensures that all timers run normally during page loading, preventing the page from getting stuck. Once the page has fully loaded, you can safely use [Clock#pause_at](./clock#pause_at) to pause the clock.

```python title="example_a455277e025b97b226ec675888cebfd13b06e296accc56892e5c4ed164cfc317.py"
```ruby
# Initialize clock with some time before the test time and let the page load
# naturally. `Date.now` will progress as the timers fire.
page.clock.install(time=datetime.datetime(2024, 12, 10, 8, 0, 0))
page.clock.install(Time.parse("2024-12-10T08:00:00Z"))
page.goto("http://localhost:3333")
page.clock.pause_at(datetime.datetime(2024, 12, 10, 10, 0, 0))

page.clock.pause_at(Time.parse("2024-12-10T10:00:00Z"))
```

## resume
Expand Down

0 comments on commit 2aacd2e

Please sign in to comment.