Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
/target
.idea
1 change: 1 addition & 0 deletions tests/fixtures/private-method/minified.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/fixtures/private-method/minified.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions tests/fixtures/private-method/original.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// terser -c -m --module tests/fixtures/private-method/original.js --source-map includeSources -o tests/fixtures/private-method/minified.js
export class ApiConnector {

#baseUrl = "https://api.example.com/";

async #makeRequest(options) {
let response = await fetch(options);
if (!response.ok) {
throw new Error("Failed to fetch!");
}
return response;
}

#buildUrl(path) {
return this.#baseUrl + path;
}

async get(url) {
return this.#makeRequest({
url: this.#buildUrl(url),
method: "GET"
});
}
}
20 changes: 20 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ fn resolves_scopes_simple() {
);
}

#[test]
fn resolves_private_method() {
let minified = fixture("private-method/minified.js");
let map = fixture("private-method/minified.js.map");

let scopes = extract_scope_names(&minified).unwrap();

let resolved_scopes = resolve_original_scopes(&minified, &map, scopes);

assert_eq!(
resolved_scopes,
[
(7..225, Some("new ApiConnector".into()), Some("new ApiConnector".into())),
(56..142, Some("ApiConnector.#t".into()), Some("ApiConnector.#makeRequest".into())),
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test would currently fail as ApiConnector.#t and ApiConnector.#r won't be translated

(142..165, Some("ApiConnector.#r".into()), Some("ApiConnector.#buildUrl".into())),
(165..224, Some("ApiConnector.get".into()), Some("ApiConnector.get".into())),
]
);
}

#[test]
fn resolves_scope_names() {
let src = std::fs::read_to_string("tests/fixtures/trace/sync.mjs").unwrap();
Expand Down