|
1 | 1 | import { RemoteValue } from "selenium-webdriver/bidi/remoteValue"; |
2 | | -import { Message, Source, source as SourceClass } from "selenium-webdriver/bidi/scriptTypes"; |
| 2 | +import { Message, ScriptSource, Source } from "selenium-webdriver/bidi/scriptTypes"; |
3 | 3 |
|
4 | 4 | function testMessageClass() { |
5 | | - const source: Source = { |
| 5 | + const scriptSource: ScriptSource = { |
6 | 6 | realm: "testRealm", |
7 | 7 | context: "testContext", |
8 | 8 | }; |
9 | 9 |
|
| 10 | + const source = new Source(scriptSource); |
| 11 | + |
10 | 12 | const remoteValue: RemoteValue = { |
11 | 13 | type: "string", |
12 | 14 | value: "testValue", |
13 | 15 | }; |
14 | 16 |
|
15 | 17 | const message = new Message("testChannel", remoteValue, source); |
16 | 18 |
|
17 | | - if (message.channel !== "testChannel") { |
18 | | - console.error("Failed: Message channel does not match expected value"); |
19 | | - } else { |
20 | | - console.log("Passed: Message channel matches expected value"); |
21 | | - } |
22 | | - |
23 | | - if (message.data !== remoteValue) { |
24 | | - console.error("Failed: Message data does not match expected value"); |
25 | | - } else { |
26 | | - console.log("Passed: Message data matches expected value"); |
27 | | - } |
28 | | - |
29 | | - if (message.source !== source) { |
30 | | - console.error("Failed: Message source does not match expected value"); |
31 | | - } else { |
32 | | - console.log("Passed: Message source matches expected value"); |
33 | | - } |
| 19 | + // $ExpectType string |
| 20 | + message.channel; |
| 21 | + // $ExpectType RemoteValue |
| 22 | + message.data; |
| 23 | + // $ExpectType Source |
| 24 | + message.source; |
34 | 25 | } |
35 | 26 |
|
36 | 27 | function testSourceClass() { |
37 | | - const sourceInstance: Source = { |
| 28 | + const scriptSource: ScriptSource = { |
38 | 29 | realm: "testRealm", |
39 | 30 | context: "testContext", |
40 | 31 | }; |
41 | 32 |
|
42 | | - const sourceObj = new SourceClass(sourceInstance); |
43 | | - |
44 | | - if (sourceObj.browsingContextId !== null) { |
45 | | - console.error("Failed: browsingContextId should be null"); |
46 | | - } else { |
47 | | - console.log("Passed: browsingContextId is null as expected"); |
48 | | - } |
| 33 | + const source = new Source(scriptSource); |
49 | 34 |
|
50 | | - if (sourceObj.realmId !== "testRealm") { |
51 | | - console.error("Failed: realmId does not match expected value"); |
52 | | - } else { |
53 | | - console.log("Passed: realmId matches expected value"); |
54 | | - } |
| 35 | + // $ExpectType string | null |
| 36 | + source.browsingContextId; |
| 37 | + // $ExpectType string |
| 38 | + source.realmId; |
55 | 39 | } |
56 | | - |
57 | | -testSourceClass(); |
58 | | -testMessageClass(); |
0 commit comments