diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index d2cb36806..e3fdcc281 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -8256,8 +8256,9 @@ fn lsp_testing_api() { let contents = r#" Deno.test({ name: "test a", - fn() { + async fn(t) { console.log("test a"); + await t.step("step of test a", () => {}); } }); "#; @@ -8287,7 +8288,6 @@ Deno.test({ assert_eq!(params.tests.len(), 1); let test = ¶ms.tests[0]; assert_eq!(test.label, "test a"); - assert!(test.steps.is_none()); assert_eq!( test.range, Some(lsp::Range { @@ -8301,6 +8301,23 @@ Deno.test({ } }) ); + let steps = test.steps.as_ref().unwrap(); + assert_eq!(steps.len(), 1); + let step = &steps[0]; + assert_eq!(step.label, "step of test a"); + assert_eq!( + step.range, + Some(lsp::Range { + start: lsp::Position { + line: 5, + character: 12, + }, + end: lsp::Position { + line: 5, + character: 16, + } + }) + ); let res = client.write_request_with_res_as::<TestRunResponseParams>( "deno/testRun", @@ -8370,6 +8387,54 @@ Deno.test({ let (method, notification) = client.read_notification::<Value>(); assert_eq!(method, "deno/testRunProgress"); + assert_eq!( + notification, + Some(json!({ + "id": 1, + "message": { + "type": "started", + "test": { + "textDocument": { + "uri": specifier, + }, + "id": id, + "stepId": step.id, + }, + } + })) + ); + + let (method, notification) = client.read_notification::<Value>(); + assert_eq!(method, "deno/testRunProgress"); + let mut notification = notification.unwrap(); + let duration = notification + .as_object_mut() + .unwrap() + .get_mut("message") + .unwrap() + .as_object_mut() + .unwrap() + .remove("duration"); + assert!(duration.is_some()); + assert_eq!( + notification, + json!({ + "id": 1, + "message": { + "type": "passed", + "test": { + "textDocument": { + "uri": specifier, + }, + "id": id, + "stepId": step.id, + }, + } + }) + ); + + let (method, notification) = client.read_notification::<Value>(); + assert_eq!(method, "deno/testRunProgress"); let notification = notification.unwrap(); let obj = notification.as_object().unwrap(); assert_eq!(obj.get("id"), Some(&json!(1))); |