-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test projects with CommonJS and ES6 imports
- Loading branch information
1 parent
fa5918a
commit 7a993ff
Showing
7 changed files
with
70 additions
and
0 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.node*.js | ||
node_modules | ||
lib | ||
testProjects |
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 |
---|---|---|
|
@@ -5,3 +5,5 @@ tags | |
coverage | ||
.idea | ||
lib | ||
testProjects/**/node_modules | ||
testProjects/**/package-lock.json |
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,29 @@ | ||
/* eslint-disable new-cap */ | ||
|
||
'use strict'; | ||
|
||
const testUtils = require('../testUtils'); | ||
const expect = require('chai').expect; | ||
|
||
const runTestProject = (projectName) => { | ||
const script = ` | ||
cd testProjects/${projectName} | ||
npm install | ||
node index.js ${testUtils.getUserStripeKey()} | ||
`; | ||
require('child_process').execSync(script); | ||
}; | ||
|
||
describe('Stripe Module', function() { | ||
this.timeout(20000); | ||
|
||
describe('imports', () => { | ||
it('should work with CommonJS imports', () => { | ||
expect(runTestProject.bind(null, 'cjs')).to.not.throw(); | ||
}); | ||
|
||
it('should work with ESModule imports', () => { | ||
expect(runTestProject.bind(null, 'mjs')).to.not.throw(); | ||
}); | ||
}); | ||
}); |
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,5 @@ | ||
const stripe = require('stripe')(process.argv[2]); | ||
|
||
stripe.customers.create({ | ||
email: 'customer@example.com', | ||
}); |
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,13 @@ | ||
{ | ||
"name": "cjs", | ||
"type": "commonjs", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"dependencies": { | ||
"stripe": "file:../../" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && 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,7 @@ | ||
import Stripe from 'stripe'; | ||
|
||
const stripe = new Stripe(process.argv[2]); | ||
|
||
const customer = await stripe.customers.create({ | ||
email: 'customer@example.com', | ||
}); |
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,13 @@ | ||
{ | ||
"name": "mjs", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"dependencies": { | ||
"stripe": "file:../../" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
} | ||
} |