@@ -13,10 +13,6 @@ describe('Load config', function() {
1313
1414 hexo . env . init = true ;
1515
16- function reset ( ) {
17- hexo . config = _ . clone ( defaultConfig ) ;
18- }
19-
2016 before ( function ( ) {
2117 return fs . mkdirs ( hexo . base_dir ) . then ( function ( ) {
2218 return hexo . init ( ) ;
@@ -27,6 +23,10 @@ describe('Load config', function() {
2723 return fs . rmdir ( hexo . base_dir ) ;
2824 } ) ;
2925
26+ beforeEach ( function ( ) {
27+ hexo . config = _ . cloneDeep ( defaultConfig ) ;
28+ } ) ;
29+
3030 it ( 'config file does not exist' , function ( ) {
3131 return loadConfig ( hexo ) . then ( function ( ) {
3232 hexo . config . should . eql ( defaultConfig ) ;
@@ -40,8 +40,7 @@ describe('Load config', function() {
4040 return loadConfig ( hexo ) ;
4141 } ) . then ( function ( ) {
4242 hexo . config . foo . should . eql ( 1 ) ;
43-
44- reset ( ) ;
43+ } ) . finally ( function ( ) {
4544 return fs . unlink ( configPath ) ;
4645 } ) ;
4746 } ) ;
@@ -53,8 +52,7 @@ describe('Load config', function() {
5352 return loadConfig ( hexo ) ;
5453 } ) . then ( function ( ) {
5554 hexo . config . baz . should . eql ( 3 ) ;
56-
57- reset ( ) ;
55+ } ) . finally ( function ( ) {
5856 return fs . unlink ( configPath ) ;
5957 } ) ;
6058 } ) ;
@@ -66,8 +64,7 @@ describe('Load config', function() {
6664 return loadConfig ( hexo ) ;
6765 } ) . then ( function ( ) {
6866 hexo . config . should . eql ( defaultConfig ) ;
69-
70- reset ( ) ;
67+ } ) . finally ( function ( ) {
7168 return fs . unlink ( configPath ) ;
7269 } ) ;
7370 } ) ;
@@ -79,8 +76,7 @@ describe('Load config', function() {
7976 return loadConfig ( hexo ) ;
8077 } ) . then ( function ( ) {
8178 hexo . config . foo . should . eql ( 1 ) ;
82-
83- reset ( ) ;
79+ } ) . finally ( function ( ) {
8480 hexo . config_path = pathFn . join ( hexo . base_dir , '_config.yml' ) ;
8581 return fs . unlink ( configPath ) ;
8682 } ) ;
@@ -95,8 +91,7 @@ describe('Load config', function() {
9591 } ) . then ( function ( ) {
9692 hexo . config . foo . should . eql ( 2 ) ;
9793 hexo . config_path . should . eql ( realPath ) ;
98-
99- reset ( ) ;
94+ } ) . finally ( function ( ) {
10095 hexo . config_path = pathFn . join ( hexo . base_dir , '_config.yml' ) ;
10196 return fs . unlink ( realPath ) ;
10297 } ) ;
@@ -113,8 +108,7 @@ describe('Load config', function() {
113108 } ) . then ( function ( ) {
114109 hexo . config . root . should . eql ( 'foo/' ) ;
115110 hexo . config . url . should . eql ( 'http://hexo.io' ) ;
116-
117- reset ( ) ;
111+ } ) . finally ( function ( ) {
118112 return fs . unlink ( hexo . config_path ) ;
119113 } ) ;
120114 } ) ;
@@ -124,8 +118,7 @@ describe('Load config', function() {
124118 return loadConfig ( hexo ) ;
125119 } ) . then ( function ( ) {
126120 hexo . public_dir . should . eql ( pathFn . resolve ( hexo . base_dir , 'foo' ) + pathFn . sep ) ;
127-
128- reset ( ) ;
121+ } ) . finally ( function ( ) {
129122 return fs . unlink ( hexo . config_path ) ;
130123 } ) ;
131124 } ) ;
@@ -135,8 +128,7 @@ describe('Load config', function() {
135128 return loadConfig ( hexo ) ;
136129 } ) . then ( function ( ) {
137130 hexo . source_dir . should . eql ( pathFn . resolve ( hexo . base_dir , 'bar' ) + pathFn . sep ) ;
138-
139- reset ( ) ;
131+ } ) . finally ( function ( ) {
140132 return fs . unlink ( hexo . config_path ) ;
141133 } ) ;
142134 } ) ;
@@ -149,8 +141,23 @@ describe('Load config', function() {
149141 hexo . theme_dir . should . eql ( pathFn . join ( hexo . base_dir , 'themes' , 'test' ) + pathFn . sep ) ;
150142 hexo . theme_script_dir . should . eql ( pathFn . join ( hexo . theme_dir , 'scripts' ) + pathFn . sep ) ;
151143 hexo . theme . base . should . eql ( hexo . theme_dir ) ;
144+ } ) . finally ( function ( ) {
145+ return fs . unlink ( hexo . config_path ) ;
146+ } ) ;
147+ } ) ;
148+
149+ it ( 'merge config' , function ( ) {
150+ var content = [
151+ 'highlight:' ,
152+ ' tab_replace: yoooo'
153+ ] . join ( '\n' ) ;
152154
153- reset ( ) ;
155+ return fs . writeFile ( hexo . config_path , content ) . then ( function ( ) {
156+ return loadConfig ( hexo ) ;
157+ } ) . then ( function ( ) {
158+ hexo . config . highlight . enable . should . be . true ;
159+ hexo . config . highlight . tab_replace . should . eql ( 'yoooo' ) ;
160+ } ) . finally ( function ( ) {
154161 return fs . unlink ( hexo . config_path ) ;
155162 } ) ;
156163 } ) ;
0 commit comments