Skip to content

Commit

Permalink
Add extension test on fetched code length
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkassimo committed Sep 30, 2018
1 parent 469771e commit c4f5adb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/deno_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,31 @@ fn test_code_fetch_no_ext() {
let r = deno_dir.code_fetch(module_specifier, containing_file);
assert!(r.is_ok());

// Test .ts extension
// Assuming cwd is the deno repo root.
let module_specifier = "./js/main";
let containing_file = cwd_string.as_str();
let r = deno_dir.code_fetch(module_specifier, containing_file);
assert!(r.is_ok());
let code_fetch_output = r.unwrap();
// could only test .ends_with to avoid include local abs path
assert!(code_fetch_output.module_name.ends_with("/js/main.ts"));
assert!(code_fetch_output.source_code.len() > 10);

// Test .js extension
// Assuming cwd is the deno repo root.
let module_specifier = "./js/mock_builtin";
let containing_file = cwd_string.as_str();
let r = deno_dir.code_fetch(module_specifier, containing_file);
assert!(r.is_ok());
let code_fetch_output = r.unwrap();
// could only test .ends_with to avoid include local abs path
assert!(
code_fetch_output
.module_name
.ends_with("/js/mock_builtin.js")
);
assert!(code_fetch_output.source_code.len() > 10);
}

#[test]
Expand Down

0 comments on commit c4f5adb

Please sign in to comment.