Skip to content

Commit

Permalink
test(windows): Normalize paths in various assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Jul 22, 2019
1 parent 7a7ca47 commit d3959bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 13 additions & 9 deletions commands/publish/__tests__/publish-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const getTwoFactorAuthRequired = require("../lib/get-two-factor-auth-required");
const commitChangeToPackage = require("@lerna-test/commit-change-to-package");
const loggingOutput = require("@lerna-test/logging-output");
const initFixture = require("@lerna-test/init-fixture")(__dirname);
const path = require("path");

// file under test
const lernaPublish = require("@lerna-test/command-runner")(require("../command"));
Expand Down Expand Up @@ -315,13 +316,16 @@ Map {

await lernaPublish(cwd)("--contents", "dist");

for (const name of ["package-1", "package-2"]) {
expect(packDirectory).toHaveBeenCalledWith(
expect.objectContaining({ name }),
expect.stringContaining(`packages/${name}/dist`),
expect.any(Object)
);
}
expect(packDirectory).toHaveBeenCalledWith(
expect.objectContaining({ name: "package-1" }),
expect.stringContaining(path.normalize("packages/package-1/dist")),
expect.any(Object)
);
expect(packDirectory).toHaveBeenCalledWith(
expect.objectContaining({ name: "package-2" }),
expect.stringContaining(path.normalize("packages/package-2/dist")),
expect.any(Object)
);
});
});

Expand All @@ -339,12 +343,12 @@ Map {

expect(packDirectory).toHaveBeenCalledWith(
expect.objectContaining({ name: "package-1" }),
expect.stringMatching(/packages\/package-1\/dist$/),
expect.stringMatching(/packages[\\/]+package-1[\\/]+dist$/),
expect.any(Object)
);
expect(packDirectory).toHaveBeenCalledWith(
expect.objectContaining({ name: "package-2" }),
expect.stringMatching(/packages\/package-2$/),
expect.stringMatching(/packages[\\/]+package-2$/),
expect.any(Object)
);
});
Expand Down
4 changes: 2 additions & 2 deletions core/package/__tests__/core-package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ describe("Package.lazy()", () => {
const pkg = Package.lazy("/foo/bar");

expect(pkg).toBeInstanceOf(Package);
expect(pkg.location).toBe("/foo/bar");
expect(pkg.location).toMatch(path.normalize("/foo/bar"));
});

it("returns package instance from package.json file argument", () => {
const pkg = Package.lazy("/foo/bar/package.json");

expect(pkg).toBeInstanceOf(Package);
expect(pkg.location).toBe("/foo/bar");
expect(pkg.location).toMatch(path.normalize("/foo/bar"));
});

it("returns package instance from json and dir arguments", () => {
Expand Down

0 comments on commit d3959bd

Please sign in to comment.