Skip to content

Commit

Permalink
fix(modifier): rename stringify pre modifier to string
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Dec 20, 2021
1 parent 599940f commit 1d61e93
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 32 deletions.
8 changes: 4 additions & 4 deletions _e2e/expect_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
jestExtendedMatcherMap,
not,
resolves,
stringify,
string,
test,
toBe,
toBeAfter,
Expand Down Expand Up @@ -1217,15 +1217,15 @@ test("passes when stringified value to be", async () => {
toBe,
},
modifierMap: {
stringify,
string,
resolves,
debug,
not,
trim,
},
});
expect(null).stringify.toBe("null");
await expect(Promise.resolve("test ")).resolves.stringify.trim.toBe(
expect(null).string.toBe("null");
await expect(Promise.resolve("test ")).resolves.string.trim.toBe(
"test",
);
});
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export { rejects } from "./modifier/rejects.ts";
export { resolves } from "./modifier/resolves.ts";
export { trim } from "./modifier/trim.ts";
export { debug } from "./modifier/debug.ts";
export { stringify } from "./modifier/stringify.ts";
export { string } from "./modifier/string.ts";
export * from "./modifier/preset.ts";

export * from "./modifier/types.ts";
Expand Down
10 changes: 5 additions & 5 deletions modifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ test("passes when trimmed string to be", () => {
});
```

### stringify
### string

Use `.stringify` to convert any `actual` to `string`. Internally, the String
Use `.string` to convert any `actual` to `string`. Internally, the String
constructor is used.

```ts
import {
defineExpect,
stringify,
string,
test,
toBe,
} from "https://deno.land/x/unitest@$VERSION/mod.ts";
Expand All @@ -121,12 +121,12 @@ const expect = defineExpect({
toBe,
},
modifierMap: {
stringify,
string,
},
});

test("passes when stringified value to be", () => {
expect(null).stringify.toBe("null");
expect(null).string.toBe("null");
});
```

Expand Down
2 changes: 1 addition & 1 deletion modifier/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export { rejects } from "./rejects.ts";
export { resolves } from "./resolves.ts";
export { trim } from "./trim.ts";
export { debug } from "./debug.ts";
export * from "./stringify.ts";
export * from "./string.ts";
export * from "./preset.ts";
12 changes: 6 additions & 6 deletions modifier/stringify.ts → modifier/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import type { PreModifier } from "./types.ts";

/** Use `.stringify` to convert any `actual` to `string`. Internally, the String
/** Use `.string` to convert any `actual` to `string`. Internally, the String
* constructor is used.
* ```ts
* import {
* defineExpect,
* stringify,
* string,
* test,
* toBe,
* } from "https://deno.land/x/unitest@$VERSION/mod.ts";
Expand All @@ -18,18 +18,18 @@ import type { PreModifier } from "./types.ts";
* toBe,
* },
* modifierMap: {
* stringify,
* string,
* },
* });
*
* test("passes when stringified value to be", () => {
* expect(null).stringify.toBe("null");
* expect(null).string.toBe("null");
* });
* ```
*/
const stringify: PreModifier<unknown, { actual: string }> = {
const string: PreModifier<unknown, { actual: string }> = {
type: "pre",
fn: (actual) => ({ actual: String(actual) }),
};

export { stringify };
export { string };
16 changes: 16 additions & 0 deletions modifier/string_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2021-Present the Unitest authors. All rights reserved. MIT license.

import { string } from "./string.ts";
import { assertEquals } from "../dev_deps.ts";
import type { PreModifierContext } from "./types.ts";

Deno.test("string", () => {
assertEquals(string.type, "pre");
assertEquals(string.fn(1, {} as PreModifierContext), { actual: "1" });
assertEquals(string.fn("test", {} as PreModifierContext), {
actual: "test",
});
assertEquals(string.fn(null, {} as PreModifierContext), {
actual: "null",
});
});
15 changes: 0 additions & 15 deletions modifier/stringify_test.ts

This file was deleted.

0 comments on commit 1d61e93

Please sign in to comment.