Repository: braintree/braintree-web-drop-in
Pull request #601 (2020-03-12 23:45:53)

Add publishing to tests
### Summary

_It would appear_ that publishing tests haven't been running. They're explicitly added to the jestconfig now.

### Checklist

- ~Added a changelog entry~

### Authors

- @gesa 


gesa: my search for the word "publishing" appears to have missed travis.yml

Patch:
diff --git a/jest.config.json b/jest.config.json
index 74c2257..6b0f699 100644
--- a/jest.config.json
+++ b/jest.config.json
@@ -11,6 +11,7 @@
     "<rootDir>/../test/"
   ],
   "testMatch": [
-    "**/unit/**/*.js"
+    "**/unit/**/*.js",
+    "**/publishing/**/*.js"
   ]
 }
diff --git a/package.json b/package.json
index b57a93c..002c0a1 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
     "test:integration:paypal-only": "RUN_PAYPAL_ONLY=true npm run test:integration",
     "test:integration:paypal-skipped": "SKIP_PAYPAL=true npm run test:integration",
     "test:integration:kill": "ps -ef | awk '/rspec/ {print $2}' | xargs kill",
-    "test:publishing": "mocha test/publishing",
+    "test:publishing": "jest test/publishing",
     "deploy:gh-pages": "./scripts/deploy-gh-pages"
   },
   "repository": {


Test patch:
diff --git a/test/publishing/dependency-check.js b/test/publishing/dependency-check.js
index 20a894a..a29bc2a 100644
--- a/test/publishing/dependency-check.js
+++ b/test/publishing/dependency-check.js
@@ -1,14 +1,12 @@
-
-var execSync = require('child_process').execSync;
-var fs = require('fs');
-
-var dependencies = require('../../package.json').dependencies;
-var dependencyNames = Object.keys(dependencies);
-var dependencyPackages = dependencyNames.map(function (depName) {
-  var depPackages = {};
-  var depVersion = dependencies[depName];
-  var cmd = 'npm view --json ' + depName + '@' + depVersion + ' dependencies';
-  var result = execSync(cmd).toString();
+const { execSync } = require('child_process');
+const fs = require('fs');
+const { dependencies } = require('../../package.json');
+const dependencyNames = Object.keys(dependencies);
+const dependencyPackages = dependencyNames.map(depName => {
+  let depPackages = {};
+  const depVersion = dependencies[depName];
+  const cmd = `npm view --json ${depName}@${depVersion} dependencies`;
+  const result = execSync(cmd).toString();
 
   if (result) {
     depPackages = JSON.parse(result);
@@ -20,22 +18,20 @@ var dependencyPackages = dependencyNames.map(function (depName) {
   };
 });
 
-describe('Shared dependency', function () {
-  dependencyPackages.forEach(function (depPkg) {
-    describe(depPkg.name, function () {
-      var sharedDependencyNames = Object.keys(depPkg.dependencies).filter(function (d) {
-        return dependencyNames.indexOf(d) !== -1;
-      });
+describe('Shared dependency', () => {
+  dependencyPackages.forEach(depPkg => {
+    describe(depPkg.name, () => {
+      const sharedDependencyNames = Object.keys(depPkg.dependencies).filter(d => dependencyNames.indexOf(d) !== -1);
 
-      sharedDependencyNames.forEach(function (sharedDepName) {
-        var sharedDepVersion = depPkg.dependencies[sharedDepName];
+      sharedDependencyNames.forEach(sharedDepName => {
+        const sharedDepVersion = depPkg.dependencies[sharedDepName];
 
-        it('uses ' + sharedDepName + '@' + sharedDepVersion, function (done) {
-          var nestedNodeModulePath = './node_modules/' + depPkg.name + '/node_modules/';
+        it(`uses ${sharedDepName}@${sharedDepVersion}`, done => {
+          const nestedNodeModulePath = `./node_modules/${depPkg.name}/node_modules/`;
 
-          fs.exists(nestedNodeModulePath + sharedDepName, function (exists) {
+          fs.exists(nestedNodeModulePath + sharedDepName, exists => {
             if (exists) {
-              done(new Error('Found ' + sharedDepName + ' with a different version in ' + depPkg.name));
+              done(new Error(`Found ${sharedDepName} with a different version in ${depPkg.name}`));
             } else {
               done();
             }
diff --git a/test/publishing/translations.js b/test/publishing/translations.js
index bf7379b..a72bff6 100644
--- a/test/publishing/translations.js
+++ b/test/publishing/translations.js
@@ -1,12 +1,9 @@
+const fs = require('fs');
+const translations = require('../../src/translations');
+const englishTranslation = require('../../src/translations/en_US');
+const englishTranslationKeys = Object.keys(englishTranslation);
 
-var fs = require('fs');
-var expect = require('chai').expect;
-
-var translations = require('../../src/translations');
-var englishTranslation = require('../../src/translations/en_US');
-var englishTranslationKeys = Object.keys(englishTranslation);
-
-var locales = fs.readdirSync('./src/translations').filter(function (fileName) {
+const locales = fs.readdirSync('./src/translations').filter(fileName => {
   if (fileName.indexOf('.js') === -1) {
     return false;
   }
@@ -16,34 +13,30 @@ var locales = fs.readdirSync('./src/translations').filter(function (fileName) {
   }
 
   return true;
-}).map(function (fileName) {
-  return fileName.substring(0, fileName.length - 3); // remove .js ending
-});
+}).map(fileName => fileName.substring(0, fileName.length - 3)); // remove .js ending
 
-describe('translations', function () {
-  locales.forEach(function (key) {
-    it(key + ' locale has a key for each english translation', function () {
-      var translation = require('../../src/translations/' + key);
-      var translationKeys = Object.keys(translation);
+describe('translations', () => {
+  locales.forEach(key => {
+    it(`${key} locale has a key for each english translation`, () => {
+      const translation = require(`../../src/translations/${key}`);
+      const translationKeys = Object.keys(translation);
 
-      englishTranslationKeys.forEach(function (translationKey) {
-        expect(translation[translationKey]).be.a('string');
+      englishTranslationKeys.forEach(translationKey => {
+        expect(typeof translation[translationKey]).toBe('string');
       });
 
-      expect(translationKeys.length).to.equal(englishTranslationKeys.length);
+      expect(translationKeys.length).toBe(englishTranslationKeys.length);
     });
   });
 
-  it('each 2 character alias corresponds to a translation object', function () {
-    Object.keys(translations.twoCharacterLocaleAliases).forEach(function (key) {
-      expect(translations.twoCharacterLocaleAliases[key]).to.be.an('object');
+  it('each 2 character alias corresponds to a translation object', () => {
+    Object.keys(translations.twoCharacterLocaleAliases).forEach(key => {
+      expect(translations.twoCharacterLocaleAliases[key]).toBeInstanceOf(Object);
     });
   });
 
-  it('fiveCharacterLocales do not clobber twoCharacterLocalAliases', function () {
-    expect(Object.keys(translations.translations).length).to.eq(
-      Object.keys(translations.twoCharacterLocaleAliases).length +
-      Object.keys(translations.fiveCharacterLocales).length
-    );
+  it('fiveCharacterLocales do not clobber twoCharacterLocalAliases', () => {
+    expect(Object.keys(translations.translations).length).toBe(Object.keys(translations.twoCharacterLocaleAliases).length +
+      Object.keys(translations.fiveCharacterLocales).length);
   });
 });