Skip to content

feat: add order service tests and jest configuration #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .eslint.js

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: NPM Publish

on:
release:
types: [created]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: PR Checks

on:
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint

- name: Run tests
run: npm test
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
lib
dist
coverage
*.md
package-lock.json
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"endOfLine": "lf"
}
18 changes: 9 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

#### Get needed params for checkout initialization:
```typescript
import InlineCheckoutApiSdk from "@xmoney/api-sdk";
import xMoney from "@xmoney/api-sdk";

const inlineCheckout = new InlineCheckoutApiSdk({
secretKey: "mySecretKey",
const xMoneyCheckout = new xMoney({
secretKey: "sk_test_secretKey",
});

const order = inlineCheckout.initializeCheckout({
siteId: 1,
const order = xMoneyCheckout.initializeCheckout({
publicKey: 'pk_test_abc123',
customer: {
identifier: "customerIdentifier",
firstName: "John",
Expand All @@ -40,16 +40,16 @@ const order = inlineCheckout.initializeCheckout({

#### How to decrypt order webhook payload:
```typescript
import InlineCheckoutApiSdk from "@xmoney/api-sdk";
import xMoney from "@xmoney/api-sdk";

const inlineCheckout = new InlineCheckoutApiSdk({
secretKey: "mySecretKey",
const xMoneyCheckout = new xMoney({
secretKey: "sk_test_secretKey",
});

const webhookPayload = 'ecryptedPayload';

console.log(
inlineCheckout.decryptOrderResponse(webhookPayload)
xMoneyCheckout.decryptOrderResponse(webhookPayload)
);
```

Expand Down
61 changes: 61 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const eslint = require('@eslint/js');
const tseslint = require('@typescript-eslint/eslint-plugin');
const tsparser = require('@typescript-eslint/parser');
const prettier = require('eslint-config-prettier');

module.exports = [
eslint.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: {
parser: tsparser,
parserOptions: {
project: './tsconfig.json',
sourceType: 'module',
},
globals: {
describe: 'readonly',
it: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
Buffer: 'readonly',
process: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint,
},
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": ["error", {
"varsIgnorePattern": "^[A-Z]",
"argsIgnorePattern": "^_",
'vars': 'all',
'args': 'after-used',
'ignoreRestSiblings': true,
}],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-inferrable-types": "off",
"require-await": "error",
"@typescript-eslint/no-floating-promises": "error",
"max-len": "off",
"semi": "off",
"comma-dangle": "off",
"eol-last": "off",
"no-undef": "off", // TypeScript handles this
"no-unused-vars": "off", // Let @typescript-eslint/no-unused-vars handle this
},
},
{
files: ['**/*.enum.ts'],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"no-unused-vars": "off",
},
},
prettier,
];
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testMatch: ['**/*.spec.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
};
Loading