CircleCI project setup (#138)
This commit is contained in:
13
.babelrc.js
Normal file
13
.babelrc.js
Normal file
@@ -0,0 +1,13 @@
|
||||
let ignore = [`**/dist`]
|
||||
|
||||
// Jest needs to compile this code, but generally we don't want this copied
|
||||
// to output folders
|
||||
if (process.env.NODE_ENV !== `test`) {
|
||||
ignore.push(`**/__tests__`)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
sourceMaps: true,
|
||||
presets: ["babel-preset-medusa-package"],
|
||||
ignore,
|
||||
}
|
||||
53
.circleci/config.yml
Normal file
53
.circleci/config.yml
Normal file
@@ -0,0 +1,53 @@
|
||||
version: 2.1
|
||||
orbs:
|
||||
node: circleci/node@3.0.0
|
||||
|
||||
executors:
|
||||
node:
|
||||
parameters:
|
||||
image:
|
||||
type: string
|
||||
# First 10.x LTS release, but old Yarn
|
||||
default: "10.14"
|
||||
docker:
|
||||
- image: circleci/node:<< parameters.image >>
|
||||
|
||||
aliases:
|
||||
install_node_modules: &install_node_modules
|
||||
run:
|
||||
name: Install node modules
|
||||
command: yarn --frozen-lockfile
|
||||
attach_to_bootstrap: &attach_to_bootstrap
|
||||
attach_workspace:
|
||||
at: ./
|
||||
|
||||
jobs:
|
||||
bootstrap:
|
||||
executor: node
|
||||
steps:
|
||||
- checkout
|
||||
- run: ./scripts/assert-changed-files.sh "packages/*|(e2e|integration)-tests/*|.circleci/*|yarn.lock"
|
||||
- <<: *install_node_modules
|
||||
- run: yarn bootstrap --concurrency=2
|
||||
# Persist the workspace again with all packages already built
|
||||
- persist_to_workspace:
|
||||
root: ./
|
||||
paths:
|
||||
- "*"
|
||||
|
||||
unit_test:
|
||||
executor: node
|
||||
steps:
|
||||
- checkout
|
||||
- run: ./scripts/assert-changed-files.sh "packages"
|
||||
- <<: *attach_to_bootstrap
|
||||
- run:
|
||||
command: node --max-old-space-size=2048 ./node_modules/.bin/jest -w 1
|
||||
|
||||
workflows:
|
||||
test_all:
|
||||
jobs:
|
||||
- bootstrap
|
||||
- unit_test:
|
||||
requires:
|
||||
- bootstrap
|
||||
4
jest-transformer.js
Normal file
4
jest-transformer.js
Normal file
@@ -0,0 +1,4 @@
|
||||
const babelPreset = require(`babel-preset-medusa-package`)();
|
||||
module.exports = require(`babel-jest`).createTransformer({
|
||||
...babelPreset,
|
||||
});
|
||||
49
jest.config.js
Normal file
49
jest.config.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const path = require(`path`);
|
||||
const glob = require(`glob`);
|
||||
const fs = require(`fs`);
|
||||
|
||||
const pkgs = glob
|
||||
.sync(`./packages/*`)
|
||||
.map((p) => p.replace(/^\./, `<rootDir>`));
|
||||
|
||||
const reMedusa = /medusa$/;
|
||||
const medusaDir = pkgs.find((p) => reMedusa.exec(p));
|
||||
const medusaBuildDirs = [`dist`].map((dir) => path.join(medusaDir, dir));
|
||||
const builtTestsDirs = pkgs
|
||||
.filter((p) => fs.existsSync(path.join(p, `src`)))
|
||||
.map((p) => path.join(p, `__tests__`));
|
||||
const distDirs = pkgs.map((p) => path.join(p, `dist`));
|
||||
const ignoreDirs = [].concat(medusaBuildDirs, builtTestsDirs, distDirs);
|
||||
|
||||
const coverageDirs = pkgs.map((p) => path.join(p, `src/**/*.js`));
|
||||
const useCoverage = !!process.env.GENERATE_JEST_REPORT;
|
||||
|
||||
module.exports = {
|
||||
notify: true,
|
||||
verbose: true,
|
||||
roots: pkgs,
|
||||
modulePathIgnorePatterns: ignoreDirs,
|
||||
coveragePathIgnorePatterns: ignoreDirs,
|
||||
testPathIgnorePatterns: [
|
||||
`<rootDir>/examples/`,
|
||||
`<rootDir>/dist/`,
|
||||
`<rootDir>/node_modules/`,
|
||||
`__tests__/fixtures`,
|
||||
],
|
||||
transform: {
|
||||
"^.+\\.[jt]s?$": `<rootDir>/jest-transformer.js`,
|
||||
},
|
||||
//moduleNameMapper: {
|
||||
// "^highlight.js$": `<rootDir>/node_modules/highlight.js/lib/index.js`,
|
||||
//},
|
||||
//snapshotSerializers: [`jest-serializer-path`],
|
||||
collectCoverageFrom: coverageDirs,
|
||||
//reporters: process.env.CI
|
||||
// ? [[`jest-silent-reporter`, { useDots: true }]].concat(
|
||||
// useCoverage ? `jest-junit` : []
|
||||
// )
|
||||
// : [`default`].concat(useCoverage ? `jest-junit` : []),
|
||||
testEnvironment: `node`,
|
||||
moduleFileExtensions: [`js`, `jsx`, `ts`, `tsx`, `json`],
|
||||
// setupFiles: [`<rootDir>/.jestSetup.js`],
|
||||
};
|
||||
16
package.json
16
package.json
@@ -2,8 +2,8 @@
|
||||
"name": "root",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/node": "^7.10.5",
|
||||
"@babel/core": "^7.12.7",
|
||||
"@babel/node": "^7.12.6",
|
||||
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
||||
"@babel/plugin-transform-classes": "^7.10.4",
|
||||
"@babel/plugin-transform-instanceof": "^7.10.4",
|
||||
@@ -11,12 +11,18 @@
|
||||
"@babel/preset-env": "^7.11.5",
|
||||
"@babel/register": "^7.11.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"axios-mock-adapter": "^1.19.0",
|
||||
"babel-jest": "^26.6.3",
|
||||
"babel-preset-medusa-package": "^1.0.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"jest": "^26.6.3",
|
||||
"lerna": "^3.22.1",
|
||||
"mongoose": "^5.10.15",
|
||||
"prettier": "^2.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"rebass": "^4.0.7"
|
||||
"scripts": {
|
||||
"bootstrap": "lerna bootstrap",
|
||||
"jest": "jest",
|
||||
"test": "jest"
|
||||
}
|
||||
}
|
||||
|
||||
1
packages/babel-preset-medusa-package/.gitignore
vendored
Normal file
1
packages/babel-preset-medusa-package/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
yarn.lock
|
||||
37
packages/babel-preset-medusa-package/.npmignore
Normal file
37
packages/babel-preset-medusa-package/.npmignore
Normal file
@@ -0,0 +1,37 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
||||
node_modules
|
||||
*.un~
|
||||
yarn.lock
|
||||
src
|
||||
flow-typed
|
||||
coverage
|
||||
decls
|
||||
examples
|
||||
|
||||
# tests
|
||||
__tests__
|
||||
26
packages/babel-preset-medusa-package/index.js
Normal file
26
packages/babel-preset-medusa-package/index.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const r = require(`./resolver`);
|
||||
|
||||
function preset(context, options = {}) {
|
||||
const { debug = false, nodeVersion = `10.14.0` } = options;
|
||||
const { NODE_ENV, BABEL_ENV } = process.env;
|
||||
|
||||
const nodeConfig = {
|
||||
corejs: 3,
|
||||
useBuiltIns: `entry`,
|
||||
targets: {
|
||||
node: nodeVersion,
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
presets: [r(`@babel/preset-env`)],
|
||||
plugins: [
|
||||
r(`@babel/plugin-proposal-class-properties`),
|
||||
r(`@babel/plugin-transform-classes`),
|
||||
r(`@babel/plugin-transform-instanceof`),
|
||||
r(`@babel/plugin-transform-runtime`),
|
||||
].filter(Boolean),
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = preset;
|
||||
27
packages/babel-preset-medusa-package/package.json
Normal file
27
packages/babel-preset-medusa-package/package.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "babel-preset-medusa-package",
|
||||
"version": "1.0.0",
|
||||
"author": "Sebastian Rindom <sebastian@mrbltech.com>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/medusajs/medusa.git",
|
||||
"directory": "packages/babel-preset-medusa-package"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
|
||||
"@babel/plugin-transform-classes": "^7.12.1",
|
||||
"@babel/plugin-transform-instanceof": "^7.12.1",
|
||||
"@babel/plugin-transform-runtime": "^7.12.1",
|
||||
"@babel/preset-env": "^7.12.7",
|
||||
"core-js": "^3.7.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.11.6"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=10.14.0"
|
||||
}
|
||||
}
|
||||
3
packages/babel-preset-medusa-package/resolver.js
Normal file
3
packages/babel-preset-medusa-package/resolver.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const r = m => require.resolve(m)
|
||||
|
||||
module.exports = r;
|
||||
@@ -15,6 +15,7 @@
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"build": "babel src --out-dir dist/ --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir dist/ --ignore **/__tests__"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"directory": "packages/medusa-core-utils"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"build": "babel src --out-dir dist/ --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir dist/ --ignore **/__tests__"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"jest": "^25.5.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"build": "babel src -d .",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir . --ignore **/__tests__"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"jest": "^25.5.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"build": "babel src -d .",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir . --ignore **/__tests__"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"jest": "^25.5.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d .",
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir . --ignore **/__tests__",
|
||||
"test": "jest"
|
||||
|
||||
@@ -2,6 +2,7 @@ export const TotalsServiceMock = {
|
||||
getTotal: jest.fn(),
|
||||
getTaxTotal: jest.fn(),
|
||||
getAllocationItemDiscounts: jest.fn(),
|
||||
getDiscountTotal: jest.fn(),
|
||||
}
|
||||
|
||||
const mock = jest.fn().mockImplementation(() => {
|
||||
|
||||
@@ -10,7 +10,6 @@ describe("KlarnaProviderService", () => {
|
||||
})
|
||||
|
||||
describe("createPayment", () => {
|
||||
let result
|
||||
const klarnaProviderService = new KlarnaProviderService(
|
||||
{
|
||||
totalsService: TotalsServiceMock,
|
||||
@@ -28,19 +27,22 @@ describe("KlarnaProviderService", () => {
|
||||
}
|
||||
)
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it("creates Klarna order", async () => {
|
||||
mockAxios.post.mockImplementation(() => {
|
||||
mockAxios.post = jest.fn().mockImplementation(() => {
|
||||
return Promise.resolve({
|
||||
order_id: "123456789",
|
||||
order_amount: 100,
|
||||
data: {
|
||||
order_id: "123456789",
|
||||
order_amount: 100,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
result = await klarnaProviderService.createPayment(carts.frCart)
|
||||
const result = await klarnaProviderService.createPayment(carts.frCart)
|
||||
expect(mockAxios.post).toHaveBeenCalledTimes(1)
|
||||
expect(result).toEqual({
|
||||
order_id: "123456789",
|
||||
order_amount: 100,
|
||||
@@ -68,7 +70,9 @@ describe("KlarnaProviderService", () => {
|
||||
it("returns Klarna order", async () => {
|
||||
mockAxios.get.mockImplementation((data) => {
|
||||
return Promise.resolve({
|
||||
order_id: "123456789",
|
||||
data: {
|
||||
order_id: "123456789",
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -133,19 +137,27 @@ describe("KlarnaProviderService", () => {
|
||||
const klarnaProviderService = new KlarnaProviderService(
|
||||
{
|
||||
totalsService: TotalsServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
},
|
||||
{
|
||||
url: "medusajs/tests",
|
||||
user: "lebronjames",
|
||||
password: "123456789",
|
||||
merchant_urls: {
|
||||
terms: "terms",
|
||||
checkout: "checkout",
|
||||
confirmation: "confirmation",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
it("returns updated Klarna order", async () => {
|
||||
mockAxios.post.mockImplementation((data) => {
|
||||
return Promise.resolve({
|
||||
order_id: "123456789",
|
||||
order_amount: 1000,
|
||||
data: {
|
||||
order_id: "123456789",
|
||||
order_amount: 1000,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -157,9 +169,7 @@ describe("KlarnaProviderService", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
order_amount: 1000,
|
||||
}
|
||||
carts.frCart
|
||||
)
|
||||
|
||||
expect(result).toEqual({
|
||||
@@ -191,7 +201,9 @@ describe("KlarnaProviderService", () => {
|
||||
return Promise.resolve()
|
||||
})
|
||||
|
||||
result = await klarnaProviderService.cancelPayment({ id: "123456789" })
|
||||
result = await klarnaProviderService.cancelPayment({
|
||||
order_id: "123456789",
|
||||
})
|
||||
|
||||
expect(result).toEqual("123456789")
|
||||
})
|
||||
@@ -206,6 +218,7 @@ describe("KlarnaProviderService", () => {
|
||||
const klarnaProviderService = new KlarnaProviderService(
|
||||
{
|
||||
totalsService: TotalsServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
},
|
||||
{
|
||||
url: "medusajs/tests",
|
||||
@@ -234,6 +247,7 @@ describe("KlarnaProviderService", () => {
|
||||
const klarnaProviderService = new KlarnaProviderService(
|
||||
{
|
||||
totalsService: TotalsServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
},
|
||||
{
|
||||
url: "medusajs/tests",
|
||||
@@ -265,6 +279,7 @@ describe("KlarnaProviderService", () => {
|
||||
const klarnaProviderService = new KlarnaProviderService(
|
||||
{
|
||||
totalsService: TotalsServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
},
|
||||
{
|
||||
url: "medusajs/tests",
|
||||
@@ -276,7 +291,9 @@ describe("KlarnaProviderService", () => {
|
||||
it("returns order id", async () => {
|
||||
mockAxios.get.mockImplementation((data) => {
|
||||
return Promise.resolve({
|
||||
order: { order_amount: 1000 },
|
||||
data: {
|
||||
order: { order_amount: 1000 },
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -285,7 +302,7 @@ describe("KlarnaProviderService", () => {
|
||||
})
|
||||
|
||||
result = await klarnaProviderService.capturePayment({
|
||||
id: "123456789",
|
||||
order_id: "123456789",
|
||||
})
|
||||
|
||||
expect(result).toEqual("123456789")
|
||||
@@ -301,6 +318,7 @@ describe("KlarnaProviderService", () => {
|
||||
const klarnaProviderService = new KlarnaProviderService(
|
||||
{
|
||||
totalsService: TotalsServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
},
|
||||
{
|
||||
url: "medusajs/tests",
|
||||
@@ -314,9 +332,9 @@ describe("KlarnaProviderService", () => {
|
||||
return Promise.resolve()
|
||||
})
|
||||
|
||||
result = await klarnaProviderService.capturePayment(
|
||||
result = await klarnaProviderService.refundPayment(
|
||||
{
|
||||
id: "123456789",
|
||||
order_id: "123456789",
|
||||
},
|
||||
1000
|
||||
)
|
||||
|
||||
@@ -151,14 +151,14 @@ var carts = {
|
||||
payment_sessions: [{
|
||||
provider_id: "stripe",
|
||||
data: {
|
||||
id: "pi_123456789",
|
||||
id: "pi_no",
|
||||
customer: _medusaTestUtils.IdMap.getId("not-lebron")
|
||||
}
|
||||
}],
|
||||
payment_method: {
|
||||
provider_id: "stripe",
|
||||
data: {
|
||||
id: "pi_123456789",
|
||||
id: "pi_no",
|
||||
customer: _medusaTestUtils.IdMap.getId("not-lebron")
|
||||
}
|
||||
},
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"@babel/node": "^7.7.4",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||
"@babel/plugin-transform-instanceof": "^7.8.3",
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"@babel/plugin-transform-runtime": "^7.7.6",
|
||||
"@babel/preset-env": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
@@ -24,10 +25,10 @@
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
"medusa-test-utils": "^0.3.0"
|
||||
"medusa-test-utils": "^1.0.11"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d .",
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir . --ignore **/__tests__",
|
||||
"test": "jest"
|
||||
@@ -36,11 +37,9 @@
|
||||
"medusa-interfaces": "1.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-classes": "^7.9.5",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"medusa-core-utils": "^1.0.10",
|
||||
"medusa-test-utils": "^1.0.11",
|
||||
"stripe": "^8.50.0"
|
||||
},
|
||||
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
|
||||
|
||||
@@ -169,7 +169,7 @@ export const carts = {
|
||||
{
|
||||
provider_id: "stripe",
|
||||
data: {
|
||||
id: "pi_123456789",
|
||||
id: "pi_no",
|
||||
customer: IdMap.getId("not-lebron"),
|
||||
},
|
||||
},
|
||||
@@ -177,7 +177,7 @@ export const carts = {
|
||||
payment_method: {
|
||||
provider_id: "stripe",
|
||||
data: {
|
||||
id: "pi_123456789",
|
||||
id: "pi_no",
|
||||
customer: IdMap.getId("not-lebron"),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
|
||||
export const StripeProviderServiceMock = {
|
||||
retrievePayment: jest.fn().mockImplementation((cart) => {
|
||||
if (cart._id === IdMap.getId("fr-cart")) {
|
||||
retrievePayment: jest.fn().mockImplementation((payData) => {
|
||||
if (payData.id === "pi_123456789") {
|
||||
return Promise.resolve({
|
||||
id: "pi",
|
||||
customer: "cus_123456789",
|
||||
})
|
||||
}
|
||||
if (cart._id === IdMap.getId("fr-cart-no-customer")) {
|
||||
if (payData.id === "pi_no") {
|
||||
return Promise.resolve({
|
||||
id: "pi",
|
||||
})
|
||||
|
||||
@@ -4,6 +4,10 @@ import { CustomerServiceMock } from "../../__mocks__/customer"
|
||||
import { carts } from "../../__mocks__/cart"
|
||||
import { TotalsServiceMock } from "../../__mocks__/totals"
|
||||
|
||||
const RegionServiceMock = {
|
||||
retrieve: jest.fn().mockReturnValue(Promise.resolve({})),
|
||||
}
|
||||
|
||||
describe("StripeProviderService", () => {
|
||||
describe("createCustomer", () => {
|
||||
let result
|
||||
@@ -12,6 +16,7 @@ describe("StripeProviderService", () => {
|
||||
const stripeProviderService = new StripeProviderService(
|
||||
{
|
||||
customerService: CustomerServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
totalsService: TotalsServiceMock,
|
||||
},
|
||||
{
|
||||
@@ -42,6 +47,7 @@ describe("StripeProviderService", () => {
|
||||
const stripeProviderService = new StripeProviderService(
|
||||
{
|
||||
customerService: CustomerServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
totalsService: TotalsServiceMock,
|
||||
},
|
||||
{
|
||||
@@ -80,6 +86,7 @@ describe("StripeProviderService", () => {
|
||||
const stripeProviderService = new StripeProviderService(
|
||||
{
|
||||
customerService: CustomerServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
totalsService: TotalsServiceMock,
|
||||
},
|
||||
{
|
||||
@@ -111,6 +118,7 @@ describe("StripeProviderService", () => {
|
||||
const stripeProviderService = new StripeProviderService(
|
||||
{
|
||||
customerService: CustomerServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
totalsService: TotalsServiceMock,
|
||||
},
|
||||
{
|
||||
@@ -144,6 +152,7 @@ describe("StripeProviderService", () => {
|
||||
const stripeProviderService = new StripeProviderService(
|
||||
{
|
||||
customerService: CustomerServiceMock,
|
||||
regionService: RegionServiceMock,
|
||||
totalsService: TotalsServiceMock,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -34,11 +34,14 @@ describe("CartSubscriber", () => {
|
||||
|
||||
expect(StripeProviderServiceMock.retrievePayment).toHaveBeenCalledTimes(1)
|
||||
expect(StripeProviderServiceMock.retrievePayment).toHaveBeenCalledWith(
|
||||
carts.frCart
|
||||
carts.frCart.payment_sessions[0].data
|
||||
)
|
||||
|
||||
expect(StripeProviderServiceMock.cancelPayment).toHaveBeenCalledTimes(1)
|
||||
expect(StripeProviderServiceMock.cancelPayment).toHaveBeenCalledWith("pi")
|
||||
expect(StripeProviderServiceMock.cancelPayment).toHaveBeenCalledWith({
|
||||
id: "pi",
|
||||
customer: "cus_123456789",
|
||||
})
|
||||
|
||||
expect(StripeProviderServiceMock.createPayment).toHaveBeenCalledTimes(1)
|
||||
expect(StripeProviderServiceMock.createPayment).toHaveBeenCalledWith(
|
||||
@@ -66,7 +69,7 @@ describe("CartSubscriber", () => {
|
||||
|
||||
expect(StripeProviderServiceMock.retrievePayment).toHaveBeenCalledTimes(1)
|
||||
expect(StripeProviderServiceMock.retrievePayment).toHaveBeenCalledWith(
|
||||
carts.frCartNoStripeCustomer
|
||||
carts.frCartNoStripeCustomer.payment_sessions[0].data
|
||||
)
|
||||
|
||||
expect(StripeProviderServiceMock.createCustomer).toHaveBeenCalledTimes(1)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"medusa-test-utils": "^1.0.11"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d .",
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir . --ignore **/__tests__",
|
||||
"test": "jest"
|
||||
|
||||
@@ -30,6 +30,7 @@ describe("LineItemService", () => {
|
||||
expect(result).toEqual({
|
||||
title: "Product 1",
|
||||
thumbnail: undefined,
|
||||
should_merge: false,
|
||||
content: {
|
||||
unit_price: 50,
|
||||
variant: {
|
||||
@@ -62,6 +63,7 @@ describe("LineItemService", () => {
|
||||
expect(result).toEqual({
|
||||
title: "Product 1",
|
||||
thumbnail: undefined,
|
||||
should_merge: false,
|
||||
content: {
|
||||
unit_price: 150,
|
||||
variant: {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
"prettier": "^2.0.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d .",
|
||||
"build": "babel src -d . --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir . --ignore **/__tests__",
|
||||
"test": "jest"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
jest.unmock("axios")
|
||||
|
||||
import BrightpearlService from "../brightpearl"
|
||||
import { mockCreateOrder } from "../../utils/brightpearl"
|
||||
import MockAdapter from "axios-mock-adapter"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"directory": "packages/medusa-test-utils"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"build": "babel src --out-dir dist/ --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir dist/ --ignore **/__tests__"
|
||||
|
||||
@@ -7,16 +7,6 @@ if (process.env.NODE_ENV !== `test`) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-transform-classes",
|
||||
"@babel/plugin-transform-instanceof",
|
||||
],
|
||||
presets: ["@babel/preset-env"],
|
||||
env: {
|
||||
test: {
|
||||
plugins: ["@babel/plugin-transform-runtime"],
|
||||
},
|
||||
},
|
||||
presets: [["babel-preset-medusa-package"]],
|
||||
ignore,
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"@babel/preset-env": "^7.7.5",
|
||||
"@babel/register": "^7.7.4",
|
||||
"@babel/runtime": "^7.7.6",
|
||||
"babel-preset-medusa-package": "^1.0.0",
|
||||
"cross-env": "^5.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.5.2",
|
||||
@@ -34,7 +35,7 @@
|
||||
"start": "nodemon --watch plugins/ --watch src/ --exec babel-node src/app.js",
|
||||
"watch": "babel -w src --out-dir dist/ --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"build": "babel src -d dist",
|
||||
"build": "babel src -d dist --ignore **/__tests__",
|
||||
"serve": "node dist/app.js",
|
||||
"test": "jest"
|
||||
},
|
||||
|
||||
@@ -4628,10 +4628,10 @@ medusa-core-utils@^1.0.10:
|
||||
joi "^17.2.1"
|
||||
joi-objectid "^3.0.1"
|
||||
|
||||
medusa-test-utils@^1.0.10:
|
||||
version "1.0.10"
|
||||
resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.0.10.tgz#8c1e9046a81cd3afa4c32c6d0d8af7e1f33bd039"
|
||||
integrity sha512-CTzlVVTEOIFh3iRsjJqt4JYtEFP+2gVZF0jXGYdhCgAxd5mFKVuE+QzLLtvTCHlT7TI7rYgPfEWCcj9LPh2vVQ==
|
||||
medusa-test-utils@^1.0.11:
|
||||
version "1.0.11"
|
||||
resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.0.11.tgz#bae901efa90426fb64818de700dc6e163820160f"
|
||||
integrity sha512-CSNb70sXOfKTndzxWtPMYq+KeYaFkSLAPUyhuwDNVvkbne0faOYF5OMCV8r3aLoQ3D1Tvjrb/XB9Qt17ycjuPw==
|
||||
dependencies:
|
||||
"@babel/plugin-transform-classes" "^7.9.5"
|
||||
medusa-core-utils "^1.0.10"
|
||||
|
||||
34
scripts/assert-changed-files.sh
Executable file
34
scripts/assert-changed-files.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
IS_CI="${CI:-false}"
|
||||
GREP_PATTERN=$1
|
||||
|
||||
if [ "$IS_CI" = true ]; then
|
||||
git config --local url."https://github.com/".insteadOf git@github.com:
|
||||
git config --local user.name "Medusajs Bot"
|
||||
git config --local user.email "core@medusa-commerce.com"
|
||||
|
||||
git fetch origin
|
||||
git merge --no-edit origin/master
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Branch has conflicts with master, rolling back test."
|
||||
git merge --abort
|
||||
fi
|
||||
|
||||
git config --local --unset user.name
|
||||
git config --local --unset user.email
|
||||
git config --local --unset url."https://github.com/".insteadOf
|
||||
fi
|
||||
|
||||
FILES_COUNT="$(git diff-tree --no-commit-id --name-only -r "$CIRCLE_BRANCH" origin/master | grep -E "$GREP_PATTERN" -c)"
|
||||
|
||||
# reset to previous state
|
||||
git reset --hard HEAD@{1}
|
||||
|
||||
if [ "$FILES_COUNT" -eq 0 ]; then
|
||||
echo "0 files matching '$GREP_PATTERN'; exiting and marking successful."
|
||||
circleci step halt || exit 1
|
||||
else
|
||||
echo "$FILES_COUNT file(s) matching '$GREP_PATTERN'; continuing."
|
||||
fi
|
||||
Reference in New Issue
Block a user