diff options
author | 2023-04-10 12:28:17 -0700 | |
---|---|---|
committer | 2023-04-10 12:28:17 -0700 | |
commit | 866970179fa419f6328d43ca2321f81c573b1a7f (patch) | |
tree | 057f9cd0072c8ef5057dbf7edd15d4dc57fe36e1 | |
parent | ce89372ebdb4ead337b32975886735a44e857b7a (diff) | |
download | bun-866970179fa419f6328d43ca2321f81c573b1a7f.tar.gz bun-866970179fa419f6328d43ca2321f81c573b1a7f.tar.zst bun-866970179fa419f6328d43ca2321f81c573b1a7f.zip |
fix `toContain` bug
-rw-r--r-- | src/bun.js/test/jest.zig | 4 | ||||
-rw-r--r-- | src/bundler/bundle_v2.zig | 2 | ||||
-rw-r--r-- | test/js/bun/test/test-test.test.ts | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 197bba03f..dcb9f8725 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -1202,9 +1202,7 @@ pub const Expect = struct { } } } else if (value.isString() and expected.isString()) { - const value_string = value.toString(globalObject).toSlice(globalObject, default_allocator).slice(); - const expected_string = expected.toString(globalObject).toSlice(globalObject, default_allocator).slice(); - if (strings.contains(value_string, expected_string)) { + if (value.stringIncludes(globalObject, expected)) { pass = true; } } else { diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 10ad9898c..496b6af10 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -333,7 +333,7 @@ pub const BundleV2 = struct { var result = resolve; var path = result.path() orelse return null; - const loader = this.bundler.options.loaders.get(path.name.ext) orelse .file; + const loader = path.loader(&this.bundler.options.loaders) orelse Loader.js; if (!loader.isJavaScriptLikeOrJSON()) return null; var entry = try this.graph.path_to_source_index_map.getOrPut(this.graph.allocator, hash orelse wyhash(0, path.text)); diff --git a/test/js/bun/test/test-test.test.ts b/test/js/bun/test/test-test.test.ts index 5154950de..906d8dd16 100644 --- a/test/js/bun/test/test-test.test.ts +++ b/test/js/bun/test/test-test.test.ts @@ -1774,6 +1774,8 @@ test("toContain()", () => { // expect("test").not.toContain("test"); expect(["test", "es"]).toContain("es"); expect("").toContain(""); + expect("").not.toContain(" "); + expect(" ").toContain(""); expect([""]).toContain(""); expect(["lemon", "lime"]).not.toContain("orange"); |