Skip to content

Commit ef7fa93

Browse files
authored
fix changing global defaults (#1576)
fix changing global defaults
2 parents ef7cde4 + 630aaa6 commit ef7fa93

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/defaults.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
let defaults = getDefaults();
2-
31
function getDefaults() {
42
return {
53
baseUrl: null,
@@ -22,11 +20,11 @@ function getDefaults() {
2220
}
2321

2422
function changeDefaults(newDefaults) {
25-
defaults = newDefaults;
23+
module.exports.defaults = newDefaults;
2624
}
2725

2826
module.exports = {
29-
defaults,
27+
defaults: getDefaults(),
3028
getDefaults,
3129
changeDefaults
3230
};

test/unit/marked-spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,12 @@ describe('Test paragraph token type', () => {
7171
expect(tokens[7].type).toBe('text');
7272
});
7373
});
74+
75+
describe('changeDefaults', () => {
76+
it('should change global defaults', () => {
77+
const { defaults, changeDefaults } = require('../../src/defaults');
78+
expect(defaults.test).toBeUndefined();
79+
changeDefaults({ test: true });
80+
expect(require('../../src/defaults').defaults.test).toBe(true);
81+
});
82+
});

0 commit comments

Comments
 (0)