Skip to content

Commit

Permalink
add integration_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Dec 6, 2023
1 parent 5e6f1a5 commit 3769c82
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 12 deletions.
12 changes: 0 additions & 12 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
changes:
default:
informational: true

ignore:
- "examples"
Empty file added fixtures/misc/中文/中文.js
Empty file.
43 changes: 43 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use std::{env, path::PathBuf};

use oxc_resolver::{Resolution, ResolveOptions, Resolver};

fn dir() -> PathBuf {
env::current_dir().unwrap()
}

fn resolve(specifier: &str) -> Resolution {
let path = dir();
Resolver::new(ResolveOptions::default()).resolve(path, specifier).unwrap()
}

#[test]
fn clone() {
let resolution = resolve("./tests/package.json");
assert_eq!(resolution.clone(), resolution);
}

#[test]
fn debug() {
let resolution = resolve("./tests/package.json");
let s = format!("{:?}", resolution);
assert!(!s.is_empty());
}

#[test]
fn eq() {
let resolution = resolve("./tests/package.json");
assert_eq!(resolution, resolution);
}

#[test]
fn package_json() {
let resolution = resolve("./tests/package.json");
assert!(resolution.package_json().is_some());
}

#[test]
fn clear_cache() {
let resolver = Resolver::new(ResolveOptions::default());
resolver.clear_cache(); // exists
}
2 changes: 2 additions & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
15 changes: 15 additions & 0 deletions tests/resolve_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::{env, path::PathBuf};

use oxc_resolver::{ResolveOptions, Resolver};

fn dir() -> PathBuf {
env::current_dir().unwrap()
}

#[test]
fn chinese_dir() {
let dir = dir();
let specifier = "./fixtures/misc/中文/中文.js";
let resolution = Resolver::new(ResolveOptions::default()).resolve(&dir, specifier);
assert_eq!(resolution.map(|r| r.into_path_buf()), Ok(dir.join("fixtures/misc/中文/中文.js")))
}

0 comments on commit 3769c82

Please sign in to comment.