@@ -44,8 +44,8 @@ def test_links():
44
44
r = get ()
45
45
about = r .html .find ('#about' , first = True )
46
46
47
- len (about .links ) == 6
48
- len (about .absolute_links ) == 6
47
+ assert len (about .links ) == 6
48
+ assert len (about .absolute_links ) == 6
49
49
50
50
51
51
def test_search ():
@@ -79,5 +79,44 @@ def test_anchor_links():
79
79
assert '#site-map' in r .html .links
80
80
81
81
82
+ def test_render ():
83
+ r = get ()
84
+ script = """
85
+ () => {
86
+ return {
87
+ width: document.documentElement.clientWidth,
88
+ height: document.documentElement.clientHeight,
89
+ deviceScaleFactor: window.devicePixelRatio,
90
+ }
91
+ }
92
+ """
93
+ val = r .html .render (script = script )
94
+ for value in ('width' , 'height' , 'deviceScaleFactor' ):
95
+ assert value in val
96
+
97
+ about = r .html .find ('#about' , first = True )
98
+ assert len (about .links ) == 6
99
+
100
+
101
+ def test_bare_render ():
102
+ doc = """<a href='https://httpbin.org'>"""
103
+ html = HTML (html = doc )
104
+ script = """
105
+ () => {
106
+ return {
107
+ width: document.documentElement.clientWidth,
108
+ height: document.documentElement.clientHeight,
109
+ deviceScaleFactor: window.devicePixelRatio,
110
+ }
111
+ }
112
+ """
113
+ val = html .render (script = script , reload = False )
114
+ for value in ('width' , 'height' , 'deviceScaleFactor' ):
115
+ assert value in val
116
+
117
+ assert html .find ('html' )
118
+ assert 'https://httpbin.org' in html .links
119
+
120
+
82
121
if __name__ == '__main__' :
83
122
test_xpath ()
0 commit comments