From 3e54f39d85fe18282140bd4a037715edf78f666c Mon Sep 17 00:00:00 2001 From: Brian Sipple Date: Mon, 10 Sep 2018 22:09:46 -0700 Subject: [PATCH] Rename `Tour.options.defaults` to `Tour.options.defaultStepOptions`. Closes [#240](https://github.com/shipshapecode/shepherd/issues/240). --- README.md | 2 +- docs/welcome/index.html | 2 +- docs/welcome/js/welcome.js | 2 +- index.md | 16 ++++++++-------- package.json | 3 ++- src/js/tour.js | 6 +++--- test/cypress/integration/test.acceptance.js | 2 +- test/cypress/utils/setup-tour.js | 8 ++++---- test/dummy/index.html | 2 +- test/unit/test.step.js | 2 +- test/unit/test.tour.js | 8 ++++---- 11 files changed, 27 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 2fa3754b8..edd469c24 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ yarn add shepherd.js ```javascript let tour = new Shepherd.Tour({ - defaults: { + defaultStepOptions: { classes: 'shepherd-theme-arrows' } }); diff --git a/docs/welcome/index.html b/docs/welcome/index.html index fe8948dff..96a7dcd3b 100644 --- a/docs/welcome/index.html +++ b/docs/welcome/index.html @@ -38,7 +38,7 @@

Example

           
             const tour = new Shepherd.Tour({
-              defaults: {
+              defaultStepOptions: {
                 classes: 'shepherd-theme-arrows'
               }
             });
diff --git a/docs/welcome/js/welcome.js b/docs/welcome/js/welcome.js
index 2cd4fc34a..3961100c0 100644
--- a/docs/welcome/js/welcome.js
+++ b/docs/welcome/js/welcome.js
@@ -8,7 +8,7 @@
   setupShepherd = function() {
     var shepherd;
     shepherd = new Shepherd.Tour({
-      defaults: {
+      defaultStepOptions: {
         showCancelLink: true
       }
     });
diff --git a/index.md b/index.md
index a3c7c9753..688e82420 100644
--- a/index.md
+++ b/index.md
@@ -35,14 +35,14 @@ First create a new `Tour` instance for your tour:
 
 ```javascript
 const tour = new Shepherd.Tour({
-  defaults: {
+  defaultStepOptions: {
     classes: 'shepherd-theme-arrows',
     scrollTo: true
   }
 });
 ```
 
-The `defaults` option allows you to specify any options which should be applied
+The `defaultStepOptions` option allows you to specify any options which should be applied
 to all this tour's steps by default.
 
 Next, add your steps:
@@ -116,7 +116,7 @@ const myTour = new Shepherd.Tour(options);
 ##### Tour Options
 
 - `steps`: An array of Step instances to initialize the tour with
-- `defaults`: Default options for Steps created through `addStep`
+- `defaultStepOptions`: Default options for Steps created through `addStep`
 - `confirmCancel`: If true, will issue a window.confirm before cancelling
 - `confirmCancelMessage`: The message to display in the confirm dialog
 
@@ -173,10 +173,10 @@ to disable.  Each button in the array is an object of the format:
   already have an `action` specified is not supported.
   You can use `events` to skip steps or navigate to specific steps, with something like:
   ```javascript
-  events: {  
-    click: function() {  
-      return Shepherd.activeTour.show('some_step_name');  
-    }  
+  events: {
+    click: function() {
+      return Shepherd.activeTour.show('some_step_name');
+    }
   }
   ```
 - `advanceOn`: An action on the page which should advance shepherd to the next step.  It can be of the form `"selector event"`, or an object with those
@@ -276,7 +276,7 @@ Individual customizations to the standard themes must be made within the CSS fil
 
 ```javascript
 let tour = new Shepherd.Tour({
-  defaults: {
+  defaultStepOptions: {
     classes: 'shepherd-theme-custom'
   }
 });
diff --git a/package.json b/package.json
index e0a87fb77..4ea516683 100644
--- a/package.json
+++ b/package.json
@@ -34,11 +34,12 @@
     "rewrite-paths": "replace 'SF:.*src' 'SF:src' coverage/lcov.info",
     "start": "yarn watch",
     "start-test-server": "http-server",
+    "test": "cross-env NODE_ENV=test webpack --config webpack.test.config.js && yarn mocha-headless-chrome",
     "test:build": "cross-env NODE_ENV=test yarn build",
     "test:ci": "yarn test:unit:ci && yarn test:cy:ci",
     "test:cy:ci": "yarn test:build && start-server-and-test start-test-server http://localhost:8080 cy:run",
     "test:cy:watch": "start-server-and-test start-test-server http://localhost:8080 cy:open",
-    "test:unit:ci": "cross-env NODE_ENV=test webpack --config webpack.test.config.js && yarn mocha-headless-chrome",
+    "test:unit:ci": "yarn test",
     "test:unit:watch": "webpack-dev-server --config webpack.test.config.js",
     "watch": "yarn clean && webpack --watch --mode development"
   },
diff --git a/src/js/tour.js b/src/js/tour.js
index fb2e2d749..a2c24a17f 100644
--- a/src/js/tour.js
+++ b/src/js/tour.js
@@ -13,7 +13,7 @@ export class Tour extends Evented {
   /**
    *
    * @param {Object} options The options for the tour
-   * @param {Object} options.defaults Default options for Steps created through `addStep`
+   * @param {Object} options.defaultStepOptions Default options for Steps created through `addStep`
    * @param {Step[]} options.steps An array of Step instances to initialize the tour with
    * @returns {Tour}
    */
@@ -198,7 +198,7 @@ export class Tour extends Evented {
       stepOptions.id = name.toString();
     }
 
-    stepOptions = Object.assign({}, this.options.defaults, stepOptions);
+    stepOptions = Object.assign({}, this.options.defaultStepOptions, stepOptions);
 
     return new Step(this, stepOptions);
   }
@@ -271,4 +271,4 @@ export class Tour extends Evented {
   }
 }
 
-export { Shepherd };
\ No newline at end of file
+export { Shepherd };
diff --git a/test/cypress/integration/test.acceptance.js b/test/cypress/integration/test.acceptance.js
index 18ddfe70b..096568280 100644
--- a/test/cypress/integration/test.acceptance.js
+++ b/test/cypress/integration/test.acceptance.js
@@ -162,7 +162,7 @@ describe('Shepherd Acceptance Tests', () => {
     });
   });
 
-  it.skip('Defaults classes applied', () => {
+  it.skip('Default classes applied', () => {
     const tour = setupTour(Shepherd, {
       classes: 'test-defaults test-more-defaults'
     });
diff --git a/test/cypress/utils/setup-tour.js b/test/cypress/utils/setup-tour.js
index c3f4f5207..93a43dad9 100644
--- a/test/cypress/utils/setup-tour.js
+++ b/test/cypress/utils/setup-tour.js
@@ -3,16 +3,16 @@ import defaultSteps from './default-steps';
 /**
  * Setup a tour
  * @param {Shepherd} Shepherd The Shepherd instance
- * @param {Object} globalDefaults A hash of the `defaults`
+ * @param {Object} globalDefaults A hash of the `defaultStepOptions`
  * @param {[Object]} customSteps An array of the steps to add to the tour
  */
 export default function(Shepherd, globalDefaults, customSteps) {
-  const defaults = Object.assign({}, {
+  const defaultStepOptions = Object.assign({}, {
     showCancelLink: true
   }, globalDefaults);
 
   let shepherd = new Shepherd.Tour({
-    defaults
+    defaultStepOptions
   });
 
   const steps = typeof customSteps === 'function' ? customSteps(shepherd) : defaultSteps(shepherd);
@@ -23,4 +23,4 @@ export default function(Shepherd, globalDefaults, customSteps) {
   });
 
   return shepherd;
-}
\ No newline at end of file
+}
diff --git a/test/dummy/index.html b/test/dummy/index.html
index 6cd3c9615..1a48a38c2 100644
--- a/test/dummy/index.html
+++ b/test/dummy/index.html
@@ -41,7 +41,7 @@ 

Example

           
             const tour = new Shepherd.Tour({
-              defaults: {
+              defaultStepOptions: {
                 classes: 'shepherd-theme-arrows'
               }
             });
diff --git a/test/unit/test.step.js b/test/unit/test.step.js
index 77bde467b..1a98d2860 100644
--- a/test/unit/test.step.js
+++ b/test/unit/test.step.js
@@ -13,7 +13,7 @@ window.Shepherd = Shepherd;
 describe('Step', () => {
   describe('Shepherd.Step()', () => {
     const instance = new Shepherd.Tour({
-      defaults: {
+      defaultStepOptions: {
         classes: 'shepherd-theme-arrows',
         scrollTo: true
       }
diff --git a/test/unit/test.tour.js b/test/unit/test.tour.js
index a194f6f39..9ba1aea18 100644
--- a/test/unit/test.tour.js
+++ b/test/unit/test.tour.js
@@ -8,7 +8,7 @@ window.Shepherd = Shepherd;
 
 describe('Tour', function() {
   let instance, shouldShowStep;
-  const defaults = {
+  const defaultStepOptions = {
     classes: 'shepherd-theme-arrows',
     scrollTo: true
   };
@@ -16,7 +16,7 @@ describe('Tour', function() {
   beforeEach(() => {
     shouldShowStep = false;
     instance = new Shepherd.Tour({
-      defaults
+      defaultStepOptions
     });
 
     instance.addStep('test', {
@@ -55,7 +55,7 @@ describe('Tour', function() {
     });
 
     it('returns the default options on the instance', function() {
-      assert.deepEqual(instance.options.defaults, {
+      assert.deepEqual(instance.options.defaultStepOptions, {
         classes: 'shepherd-theme-arrows',
         scrollTo: true
       });
@@ -145,7 +145,7 @@ describe('Tour', function() {
   describe('.cancel()', function() {
     it('shows confirm dialog when confirmCancel is true', function() {
       instance = new Shepherd.Tour({
-        defaults,
+        defaultStepOptions,
         confirmCancel: true,
         confirmCancelMessage: 'Confirm cancel?'
       });