Skip to content

Commit d342f1c

Browse files
chore: add some tests (#42)
* chore: add github actions * chore: add some tests based off https://github.com/ember-cli-deploy/ember-cli-deploy-s3 Co-authored-by: Patrick Berkeley <[email protected]>
1 parent 8f08914 commit d342f1c

File tree

12 files changed

+1420
-20
lines changed

12 files changed

+1420
-20
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = {
2121
files: [
2222
'.eslintrc.js',
2323
'.prettierrc.js',
24-
'./tests/.eslintrc.js',
2524
'.template-lintrc.js',
2625
'ember-cli-build.js',
2726
'index.js',

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module.exports = {
5252
let overwrite = this.readConfig('overwrite');
5353
let includeAppVersion = this.readConfig('includeAppVersion');
5454
let uploadMinifiedFile = this.readConfig('uploadMinifiedFile');
55+
let upload = this.readConfig('_upload') || request;
5556

5657
log('Uploading sourcemaps to bugsnag', { verbose: true });
5758

@@ -82,7 +83,7 @@ module.exports = {
8283
formData.appVersion = revisionKey;
8384
}
8485

85-
return request({
86+
return upload({
8687
uri: 'https://upload.bugsnag.com',
8788
method: 'POST',
8889
formData: formData
@@ -97,13 +98,14 @@ module.exports = {
9798
didUpload() {
9899
this.log('Deleting sourcemaps', { verbose: true });
99100
let deleteSourcemaps = this.readConfig('deleteSourcemaps');
101+
let deleteFile = this.readConfig('_deleteFile') || fs.unlink;
100102
if (deleteSourcemaps) {
101103
let distDir = this.readConfig('distDir');
102104
let distFiles = this.readConfig('distFiles');
103105
let mapFilePaths = fetchFilePathsByType(distFiles, distDir, 'map');
104106
let promises = mapFilePaths.map(function(mapFilePath) {
105107
return new RSVP.Promise(function(resolve, reject) {
106-
fs.unlink(mapFilePath, function(err) {
108+
deleteFile(mapFilePath, function(err) {
107109
if (err) {
108110
reject();
109111
} else {

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
},
2020
"repository": "https://github.com/IcarusWorks/ember-cli-deploy-bugsnag",
2121
"scripts": {
22-
"build": "ember build",
23-
"start": "ember server",
24-
"lint": "eslint .",
25-
"lint:fix": "eslint . --fix",
26-
"test": "npm run lint"
22+
"build": "ember build --environment=production",
23+
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
24+
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
25+
"lint:js": "eslint .",
26+
"lint:js:fix": "eslint . --fix",
27+
"start": "ember serve",
28+
"test": "npm-run-all lint test:*",
29+
"test:node": "node tests/runner.js"
2730
},
2831
"dependencies": {
2932
"ember-cli-babel": "^6.16.0",
@@ -34,12 +37,16 @@
3437
"rsvp": "^4.8.4"
3538
},
3639
"devDependencies": {
40+
"chai": "^4.3.7",
41+
"chai-as-promised": "^7.1.1",
3742
"ember-cli": "3.4.3",
3843
"ember-cli-eslint": "^4.2.3",
3944
"eslint-config-prettier": "^3.0.1",
4045
"eslint-plugin-ember": "^5.2.0",
4146
"eslint-plugin-node": "^7.0.1",
4247
"eslint-plugin-prettier": "^2.6.2",
48+
"mocha": "^9.2.2",
49+
"npm-run-all": "^4.1.5",
4350
"prettier": "^1.14.3"
4451
},
4552
"engines": {

tests/.eslintrc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/*eslint-env node*/
22

33
module.exports = {
4-
env: {
5-
embertest: true
4+
globals: {
5+
describe: true,
6+
before: true,
7+
beforeEach: true,
8+
it: true
69
}
710
};

tests/fixtures/dist/assets/app.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
body: {}

tests/fixtures/dist/assets/app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var a = 1;
2+
a;

tests/fixtures/dist/assets/app.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

tests/fixtures/dist/index

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>Some HTML</p>

tests/fixtures/dist/manifest.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
app.css
2+
app.js

tests/runner.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*eslint-env node*/
2+
'use strict';
3+
4+
var glob = require('glob');
5+
var Mocha = require('mocha');
6+
7+
var mocha = new Mocha({
8+
reporter: 'spec'
9+
});
10+
11+
var arg = process.argv[2];
12+
var root = 'tests/';
13+
14+
function addFiles(mocha, files) {
15+
glob.sync(root + files).forEach(mocha.addFile.bind(mocha));
16+
}
17+
18+
addFiles(mocha, '/**/*-nodetest.js');
19+
20+
if (arg === 'all') {
21+
addFiles(mocha, '/**/*-nodetest-slow.js');
22+
}
23+
24+
mocha.run(function(failures) {
25+
process.on('exit', function() {
26+
process.exit(failures);
27+
});
28+
});

0 commit comments

Comments
 (0)