From 3769c8292ca04631f73c7ae2afaae1ccbaa47cdc Mon Sep 17 00:00:00 2001 From: Boshen Date: Wed, 6 Dec 2023 15:45:57 +0800 Subject: [PATCH] add integration_test --- .github/codecov.yml | 12 ------ .../\344\270\255\346\226\207.js" | 0 tests/integration_test.rs | 43 +++++++++++++++++++ tests/package.json | 2 + tests/resolve_test.rs | 15 +++++++ 5 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 "fixtures/misc/\344\270\255\346\226\207/\344\270\255\346\226\207.js" create mode 100644 tests/integration_test.rs create mode 100644 tests/package.json create mode 100644 tests/resolve_test.rs diff --git a/.github/codecov.yml b/.github/codecov.yml index 0610268a..7a07bf8d 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -1,14 +1,2 @@ -coverage: - status: - project: - default: - informational: true - patch: - default: - informational: true - changes: - default: - informational: true - ignore: - "examples" diff --git "a/fixtures/misc/\344\270\255\346\226\207/\344\270\255\346\226\207.js" "b/fixtures/misc/\344\270\255\346\226\207/\344\270\255\346\226\207.js" new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration_test.rs b/tests/integration_test.rs new file mode 100644 index 00000000..4d205372 --- /dev/null +++ b/tests/integration_test.rs @@ -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 +} diff --git a/tests/package.json b/tests/package.json new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/tests/package.json @@ -0,0 +1,2 @@ +{ +} diff --git a/tests/resolve_test.rs b/tests/resolve_test.rs new file mode 100644 index 00000000..68a1b3be --- /dev/null +++ b/tests/resolve_test.rs @@ -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"))) +}