Skip to content

Commit 4e30e09

Browse files
committed
add test(wip); add misc implementation
1 parent 8cef286 commit 4e30e09

File tree

11 files changed

+8370
-1654
lines changed

11 files changed

+8370
-1654
lines changed

.github/workflows/publish.yml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,55 @@
11
name: Publish Package
22

33
on:
4-
release:
5-
types: [published]
4+
push:
5+
branches:
6+
- main
67

78
jobs:
8-
build:
9+
publish:
910
runs-on: ubuntu-latest
11+
1012
steps:
11-
- uses: actions/checkout@v3
12-
- uses: actions/setup-node@v3
13+
- uses: actions/checkout@v4
14+
with:
15+
token: ${{ secrets.GITHUB_TOKEN }}
16+
17+
- name: Setup node
18+
uses: actions/setup-node@v4
1319
with:
14-
node-version: '16.x'
20+
node-version: "18.x"
21+
cache: "npm"
1522
registry-url: https://registry.npmjs.org/
1623

17-
- name: gitconfig
24+
- name: Configure git
1825
run: |
19-
git config --global user.email "${{github.actor}}@users.noreply.github.com"
20-
git config --global user.name "${{github.actor}}"
26+
git config user.name "github-actions[bot]"
27+
git config user.email "github-actions[bot]@users.noreply.github.com"
2128
22-
- run: npm install
23-
- run: npm version ${{ github.event.release.tag_name }}
24-
- name: Create .env with github secrets and run script
25-
run: |
26-
touch .env
27-
echo GITHUB_TOKEN=$GITHUB_TOKEN >> .env
28-
echo NODE_AUTH_TOKEN=$NODE_AUTH_TOKEN >> .env
29-
npm publish --access public
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run test
33+
run: npm run test
34+
35+
- name: Build
36+
run: npm run build
37+
38+
- name: Publish
39+
run: npm publish
3040
env:
3141
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
43+
- name: Get package version
44+
id: package-version
45+
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
46+
47+
- name: Create release
48+
uses: actions/crete-release@v1
49+
env:
3250
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
tag_name: v${{ steps.package-version.outputs.version }}
53+
release_name: Release v${{ steps.package-version.outputs.version }}
54+
draft: false
55+
prerelease: false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ All methods use promise meaning you can either use the `async...await` or `then.
6363
- [ ] Disputes
6464
- [x] Refunds
6565
- [x] Verification
66-
- [ ] Miscellaneous
66+
- [x] Miscellaneous
6767

6868
## CONTRIBUTING
6969

__tests__/paystack.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import axios from "axios";
2+
import { Paystack } from "../src/paystack";
3+
4+
jest.mock('axios')
5+
const Axios = axios as jest.Mocked<typeof axios>;
6+
7+
beforeEach(() => {
8+
Axios.create.mockReturnValue({
9+
interceptors: { response: { use: jest.fn() } }
10+
} as any)
11+
});
12+
13+
describe('PaystackSDK', () => {
14+
it('sets correct headers on initialization', () => {
15+
new Paystack('test-key')
16+
17+
expect(axios.create).toHaveBeenCalledWith({
18+
baseURL: 'https://api.paystack.co',
19+
headers: {
20+
Authorization: 'Bearer test-key',
21+
'Content-Type': 'application/json'
22+
}
23+
})
24+
})
25+
})

jest.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node'
4+
}

0 commit comments

Comments
 (0)