Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smac89 committed May 1, 2020
1 parent cf57eb0 commit 3f1a221
Show file tree
Hide file tree
Showing 14 changed files with 3,988 additions and 4,987 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true

[{package,package-lock,tsconfig}.json]
indent_size = 3

[*.{ts,js}]
indent_size = 4
7 changes: 0 additions & 7 deletions .prettierignore

This file was deleted.

6 changes: 2 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"files.exclude": {
"node_modules": true
},
"prettier.printWidth": 120,
"prettier.tabWidth": 4
}
}
}
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing guidelines

<h2 style="color: red;">DON'T</h2>

### **Never create a pull request for master.**

<h2 style="color: green;">DO</h2>

- ### Checkout a release branch corresponding to the version you want to contribute to
- ### Make your changes and create a pull request
- ### Your request will be merged once it is reviewed

## Thank you for reading
31 changes: 0 additions & 31 deletions __tests__/action.test.ts

This file was deleted.

21 changes: 21 additions & 0 deletions __tests__/functions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
beforeEach(() => jest.resetModules());

describe("getPreferredRef()", () => {
test("Should be heads", () => {
jest.doMock("src", () => ({
preferences: { preferBranchRelease: true },
}));
return import("src/functions").then(({ getPreferredRef }) =>
expect(getPreferredRef()).toBe("heads")
);
});

test("Should be tags", () => {
jest.doMock("src", () => ({
preferences: { preferBranchRelease: false },
}));
return import("src/functions").then(({ getPreferredRef }) =>
expect(getPreferredRef()).toBe("tags")
);
});
});
36 changes: 36 additions & 0 deletions __tests__/preferences.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
beforeEach(() => jest.resetModules());

describe("preferences.publishLatestTag", () => {
it("Should have been set to false", () =>
import("src").then(({ preferences }) =>
expect(preferences.publishLatestTag).toBe(false)
));

it("Should have been set to true when deprecated input is true", () => {
process.env.INPUT_PUBLISH_LATEST = "true";
return import("src").then(({ preferences }) =>
expect(preferences.publishLatestTag).toBe(true)
);
});

it("Should have been set to true when input is true", () => {
process.env.INPUT_PUBLISH_LATEST_TAG = "true";
return import("src").then(({ preferences }) =>
expect(preferences.publishLatestTag).toBe(true)
);
});
});

describe("preferences.preferBranchRelease", () => {
it("Should have been set to false", () =>
import("src").then(({ preferences }) =>
expect(preferences.preferBranchRelease).toBe(false)
));

it("Should have been set to true when input is true", () => {
process.env.INPUT_PREFER_BRANCH_RELEASES = "true";
return import("src").then(({ preferences }) =>
expect(preferences.preferBranchRelease).toBe(true)
);
});
});
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://kulshekhar.github.io/ts-jest/user/config/
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
modulePaths: ["<rootDir>/"],
verbose: true,
globalSetup: "<rootDir>/test-setup.ts",
};
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 3f1a221

Please sign in to comment.