Skip to content

Commit 7c97504

Browse files
committed
chore: added separate test for class expressions
1 parent ad8e266 commit 7c97504

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

tests/class_expression_cjs/mod.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
4+
**/
5+
class UndiciBase {
6+
async fetch (url) {
7+
return 42;
8+
}
9+
}
10+
class Undici extends UndiciBase {
11+
async fetch (url) {
12+
return super.fetch(url);
13+
}
14+
}
15+
16+
module.exports = Undici;
17+

tests/class_expression_cjs/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use crate::common::*;
2+
use orchestrion_js::*;
3+
4+
#[test]
5+
fn class_method_cjs() {
6+
transpile_and_test(
7+
file!(),
8+
false,
9+
Config::new_single(InstrumentationConfig::new(
10+
"Undici:fetch",
11+
test_module_matcher(),
12+
FunctionQuery::class_method("Undici", "fetch", FunctionKind::Async),
13+
)),
14+
);
15+
}

tests/class_expression_cjs/test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
4+
**/
5+
const Undici = require('./instrumented.js');
6+
const { assert, getContext } = require('../common/preamble.js');
7+
const context = getContext('orchestrion:undici:Undici:fetch');
8+
(async () => {
9+
const undici = new Undici;
10+
const result = await undici.fetch('https://example.com');
11+
assert.strictEqual(result, 42);
12+
assert.deepStrictEqual(context, {
13+
start: true,
14+
end: true,
15+
asyncStart: 42,
16+
asyncEnd: 42
17+
});
18+
})();

tests/class_method_cjs/mod.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ class UndiciBase {
77
return 42;
88
}
99
}
10-
module.exports = class Undici extends UndiciBase {
10+
class Undici extends UndiciBase {
1111
async fetch (url) {
1212
return super.fetch(url);
1313
}
14-
};
14+
}
1515

16+
module.exports = Undici;

tests/instrumentor_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
**/
55
mod common;
66

7+
mod class_expression_cjs;
78
mod class_method_cjs;
89
mod constructor_cjs;
910
mod constructor_mjs;

0 commit comments

Comments
 (0)