Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Nov 21, 2023
1 parent 6e47978 commit a7b5f5d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
10 changes: 3 additions & 7 deletions lib/helpers/regexes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ describe("replaceVersionInContent", () => {
});

it("should not replace the version outside of the project definition", () => {
expect(replaceVersionInContent('version: "0.0.0-dev"', "1.0.0")).toBe(
'version: "0.0.0-dev"',
);

expect(replaceVersionInContent('@version "0.0.0-dev"', "1.0.0")).toBe(
'@version "0.0.0-dev"',
);
expect(() =>
replaceVersionInContent('version: "0.0.0-dev"', "1.0.0"),
).toThrow();
});

it("should preserve indentation and newline", () => {
Expand Down
46 changes: 46 additions & 0 deletions tests/fixtures/mix-attribute-trap.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
defmodule HelloWorld.MixProject do
use Mix.Project

@version "{{VERSION}}"

def some_config do
[
app: :hello_world,
version: "1.2.3",
some_config_key: "some string"
]
end

def project do
[
app: :hello_world,
version: @version,
elixir: "~> 1.15",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end

def some_other_config do
[
app: :hello_world,
version: "4.5.6",
some_other_config_key: "some other string"
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
]
end
end
4 changes: 2 additions & 2 deletions tests/prepare.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("prepare", () => {
});

it("should update project version in mix.exs", async () => {
expect.assertions(4);
expect.assertions(6);

for (let asAttribute of [false, true]) {
const { cwd, path } = createTestProject("0.0.0-dev", asAttribute);
Expand All @@ -57,7 +57,7 @@ describe("prepare", () => {
});

it("should not update the version outside of the project definition in mix.exs", async () => {
expect.assertions(4);
expect.assertions(10);

for (let asAttribute of [false, true]) {
const { cwd, path } = createTestProject("0.0.0-dev", asAttribute, "trap");
Expand Down

0 comments on commit a7b5f5d

Please sign in to comment.