Skip to content

Commit

Permalink
fix changing global defaults (#1576)
Browse files Browse the repository at this point in the history
fix changing global defaults
  • Loading branch information
UziTech authored Dec 5, 2019
2 parents ef7cde4 + 630aaa6 commit ef7fa93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/defaults.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
let defaults = getDefaults();

function getDefaults() {
return {
baseUrl: null,
Expand All @@ -22,11 +20,11 @@ function getDefaults() {
}

function changeDefaults(newDefaults) {
defaults = newDefaults;
module.exports.defaults = newDefaults;
}

module.exports = {
defaults,
defaults: getDefaults(),
getDefaults,
changeDefaults
};
9 changes: 9 additions & 0 deletions test/unit/marked-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ describe('Test paragraph token type', () => {
expect(tokens[7].type).toBe('text');
});
});

describe('changeDefaults', () => {
it('should change global defaults', () => {
const { defaults, changeDefaults } = require('../../src/defaults');
expect(defaults.test).toBeUndefined();
changeDefaults({ test: true });
expect(require('../../src/defaults').defaults.test).toBe(true);
});
});

1 comment on commit ef7fa93

@vercel
Copy link

@vercel vercel bot commented on ef7fa93 Dec 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.