generated from JS-DevTools/template-node-typescript
-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathformat-publish-result.test.ts
52 lines (45 loc) · 1.75 KB
/
format-publish-result.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { describe, it, expect } from "vitest";
import * as subject from "../format-publish-result.js";
import type { PackageManifest } from "../read-manifest.js";
import type { NormalizedOptions } from "../normalize-options.js";
import type { PublishResult } from "../compare-and-publish/index.js";
describe("formatPublishResult", () => {
it("should say if a publish was skipped", () => {
const result = subject.formatPublishResult(
{ name: "cool-package", version: "1.2.3" } as PackageManifest,
{} as NormalizedOptions,
{ id: undefined } as PublishResult
);
expect(result).toMatch(/cool-package@1\.2\.3.+skipped/);
});
it("should say if a publish was a dry run", () => {
const result = subject.formatPublishResult(
{ name: "cool-package", version: "1.2.3" } as PackageManifest,
{ dryRun: { value: true } } as NormalizedOptions,
{
id: "[email protected]",
files: [{ path: "cool-file-1", size: 1 }],
} as PublishResult
);
expect(result).toMatch(/cool-package@1\.2\.3.+DRY RUN/);
});
it("should print files", () => {
const result = subject.formatPublishResult(
{ name: "cool-package", version: "1.2.3" } as PackageManifest,
{ dryRun: { value: false } } as NormalizedOptions,
{
id: "[email protected]",
files: [
{ path: "cool-file-1", size: 1 },
{ path: "cool-file-2", size: 1234 },
{ path: "cool-file-3", size: 5_678_910 },
],
} as PublishResult
);
expect(result).not.toMatch(/DRY RUN/);
expect(result).toContain("[email protected]");
expect(result).toMatch(/1 B.+cool-file-1/);
expect(result).toMatch(/1.2 kB.+cool-file-2/);
expect(result).toMatch(/5.7 MB.+cool-file-3/);
});
});