Skip to content

Commit

Permalink
chore: add some tests (#42)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
pdud and patrickberkeley authored Jan 6, 2023
1 parent 8f08914 commit d342f1c
Show file tree
Hide file tree
Showing 12 changed files with 1,420 additions and 20 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = {
files: [
'.eslintrc.js',
'.prettierrc.js',
'./tests/.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = {
let overwrite = this.readConfig('overwrite');
let includeAppVersion = this.readConfig('includeAppVersion');
let uploadMinifiedFile = this.readConfig('uploadMinifiedFile');
let upload = this.readConfig('_upload') || request;

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

Expand Down Expand Up @@ -82,7 +83,7 @@ module.exports = {
formData.appVersion = revisionKey;
}

return request({
return upload({
uri: 'https://upload.bugsnag.com',
method: 'POST',
formData: formData
Expand All @@ -97,13 +98,14 @@ module.exports = {
didUpload() {
this.log('Deleting sourcemaps', { verbose: true });
let deleteSourcemaps = this.readConfig('deleteSourcemaps');
let deleteFile = this.readConfig('_deleteFile') || fs.unlink;
if (deleteSourcemaps) {
let distDir = this.readConfig('distDir');
let distFiles = this.readConfig('distFiles');
let mapFilePaths = fetchFilePathsByType(distFiles, distDir, 'map');
let promises = mapFilePaths.map(function(mapFilePath) {
return new RSVP.Promise(function(resolve, reject) {
fs.unlink(mapFilePath, function(err) {
deleteFile(mapFilePath, function(err) {
if (err) {
reject();
} else {
Expand Down
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
},
"repository": "https://github.com/IcarusWorks/ember-cli-deploy-bugsnag",
"scripts": {
"build": "ember build",
"start": "ember server",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "npm run lint"
"build": "ember build --environment=production",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix",
"start": "ember serve",
"test": "npm-run-all lint test:*",
"test:node": "node tests/runner.js"
},
"dependencies": {
"ember-cli-babel": "^6.16.0",
Expand All @@ -34,12 +37,16 @@
"rsvp": "^4.8.4"
},
"devDependencies": {
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"ember-cli": "3.4.3",
"ember-cli-eslint": "^4.2.3",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-ember": "^5.2.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-prettier": "^2.6.2",
"mocha": "^9.2.2",
"npm-run-all": "^4.1.5",
"prettier": "^1.14.3"
},
"engines": {
Expand Down
7 changes: 5 additions & 2 deletions tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/*eslint-env node*/

module.exports = {
env: {
embertest: true
globals: {
describe: true,
before: true,
beforeEach: true,
it: true
}
};
1 change: 1 addition & 0 deletions tests/fixtures/dist/assets/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
body: {}
2 changes: 2 additions & 0 deletions tests/fixtures/dist/assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var a = 1;
a;
1 change: 1 addition & 0 deletions tests/fixtures/dist/assets/app.map
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions tests/fixtures/dist/index
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Some HTML</p>
2 changes: 2 additions & 0 deletions tests/fixtures/dist/manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
app.css
app.js
28 changes: 28 additions & 0 deletions tests/runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*eslint-env node*/
'use strict';

var glob = require('glob');
var Mocha = require('mocha');

var mocha = new Mocha({
reporter: 'spec'
});

var arg = process.argv[2];
var root = 'tests/';

function addFiles(mocha, files) {
glob.sync(root + files).forEach(mocha.addFile.bind(mocha));
}

addFiles(mocha, '/**/*-nodetest.js');

if (arg === 'all') {
addFiles(mocha, '/**/*-nodetest-slow.js');
}

mocha.run(function(failures) {
process.on('exit', function() {
process.exit(failures);
});
});
Loading

0 comments on commit d342f1c

Please sign in to comment.