Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
195 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,4 @@ jobs: | |
- run: yarn test:pretty | ||
- run: yarn test | ||
- run: yarn test:types | ||
- run: yarn test:build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Generated by yarn build | ||
export const VERSION = '4.0.0'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
npm pack | ||
|
||
mkdir ./build 2>/dev/null || true | ||
mv -f paddle-sdk*.tgz ./build/paddle-sdk.tgz | ||
tar xf ./build/paddle-sdk.tgz --directory=./build/ | ||
|
||
cd tests/esm/ | ||
rm -f package-lock.json | ||
yarn | ||
node ./index.js | ||
|
||
cd ../cjs/ | ||
rm -f package-lock.json | ||
yarn | ||
node ./index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const assert = require('assert'); | ||
const nock = require('nock'); | ||
const { PaddleSDK } = require('paddle-sdk'); | ||
|
||
const SERVER = 'http://test.paddle.com'; | ||
|
||
async function run() { | ||
// https://paddle.com/docs/api-list-products | ||
nock(SERVER, { | ||
reqheaders: { | ||
'user-agent': /paddle-sdk\/\d+/, | ||
}, | ||
}).post('/product/get_products', { | ||
vendor_id: 'test-id', | ||
vendor_auth_code: 'test-key', | ||
}).reply(200, { | ||
success: true, | ||
response: { | ||
total: 2, | ||
count: 2, | ||
products: [ | ||
{ | ||
id: 10000, | ||
name: 'A Product', | ||
description: 'A description of the product.', | ||
base_price: 58, | ||
sale_price: null, | ||
screenshots: [], | ||
icon: 'https://paddle-static.s3.amazonaws.com/email/2013-04-10/og.png', | ||
}, | ||
{ | ||
id: 20000, | ||
name: 'Another Product', | ||
description: null, | ||
base_price: 39.99, | ||
sale_price: null, | ||
screenshots: [], | ||
icon: 'https://paddle.s3.amazonaws.com/user/91/489278geekbench.png', | ||
}, | ||
], | ||
}, | ||
});; | ||
|
||
const paddle = new PaddleSDK('test-id', 'test-key', '', { | ||
server: SERVER, | ||
}); | ||
|
||
const products = await paddle.getProducts(); | ||
|
||
assert.strictEqual(typeof products, 'object'); | ||
assert.strictEqual(products.count, 2); | ||
assert.strictEqual(products.products.length, 2); | ||
assert.strictEqual(products.products[0].id, 10000); | ||
assert.strictEqual(products.products[1].id, 20000); | ||
|
||
nock.cleanAll(); | ||
} | ||
|
||
run().then(() => { | ||
console.log('OK'); | ||
}).catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "test-cjs", | ||
"type": "commonjs", | ||
"dependencies": { | ||
"paddle-sdk": "file:../../build/package" | ||
}, | ||
"volta": { | ||
"node": "14.21.3", | ||
"yarn": "1.22.10" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import assert from 'assert'; | ||
import nock from 'nock'; | ||
import { PaddleSDK } from 'paddle-sdk'; | ||
|
||
const SERVER = 'http://test.paddle.com'; | ||
|
||
async function run() { | ||
// https://paddle.com/docs/api-list-products | ||
nock(SERVER, { | ||
reqheaders: { | ||
'user-agent': /paddle-sdk\/\d+/, | ||
}, | ||
}).post('/product/get_products', { | ||
vendor_id: 'test-id', | ||
vendor_auth_code: 'test-key', | ||
}).reply(200, { | ||
success: true, | ||
response: { | ||
total: 2, | ||
count: 2, | ||
products: [ | ||
{ | ||
id: 10000, | ||
name: 'A Product', | ||
description: 'A description of the product.', | ||
base_price: 58, | ||
sale_price: null, | ||
screenshots: [], | ||
icon: 'https://paddle-static.s3.amazonaws.com/email/2013-04-10/og.png', | ||
}, | ||
{ | ||
id: 20000, | ||
name: 'Another Product', | ||
description: null, | ||
base_price: 39.99, | ||
sale_price: null, | ||
screenshots: [], | ||
icon: 'https://paddle.s3.amazonaws.com/user/91/489278geekbench.png', | ||
}, | ||
], | ||
}, | ||
});; | ||
|
||
const paddle = new PaddleSDK('test-id', 'test-key', '', { | ||
server: SERVER, | ||
}); | ||
|
||
const products = await paddle.getProducts(); | ||
|
||
assert.strictEqual(typeof products, 'object'); | ||
assert.strictEqual(products.count, 2); | ||
assert.strictEqual(products.products.length, 2); | ||
assert.strictEqual(products.products[0].id, 10000); | ||
assert.strictEqual(products.products[1].id, 20000); | ||
|
||
nock.cleanAll(); | ||
} | ||
|
||
await run(); | ||
|
||
console.log('OK'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "test-esm", | ||
"type": "module", | ||
"dependencies": { | ||
"paddle-sdk": "file:../../build/package" | ||
}, | ||
"volta": { | ||
"node": "14.21.3", | ||
"yarn": "1.22.10" | ||
} | ||
} |