@@ -2,6 +2,10 @@ const test = require('ava')
22const rewire = require ( 'rewire' )
33const standardRewired = rewire ( '..' )
44const standard = require ( '..' )
5+ const path = require ( 'path' )
6+ const fixtures = path . join ( __dirname , 'fixtures' )
7+ const reshape = require ( 'reshape' )
8+ const fs = require ( 'fs' )
59
610test ( 'content options passed correctly' , ( t ) => {
711 const undo = standardRewired . __set__ ( 'content' , ( opts ) => {
@@ -56,7 +60,7 @@ test('defaults come out right', (t) => {
5660 t . truthy ( out . parser . name === 'SugarMLParser' )
5761 t . truthy ( Object . keys ( out . locals ) . length === 0 )
5862 t . truthy ( out . filename === undefined )
59- t . truthy ( out . plugins . length === 6 )
63+ t . truthy ( out . plugins . length === 7 )
6064} )
6165
6266test ( 'content defaults' , ( t ) => {
@@ -104,6 +108,21 @@ test('minify option', (t) => {
104108 t . truthy ( out . plugins [ out . plugins . length - 1 ] . name === 'minifyPlugin' )
105109} )
106110
111+ test ( 'locals option' , ( t ) => {
112+ const undo = standardRewired . __set__ ( 'evalCode' , ( opts ) => {
113+ t . truthy ( opts === true )
114+ } )
115+ standardRewired ( { locals : true } )
116+ undo ( )
117+ } )
118+
119+ test ( 'template option' , ( t ) => {
120+ const out = standard ( )
121+ t . truthy ( out . plugins [ 3 ] . name === 'evalCodePlugin' )
122+ const out2 = standard ( { template : true } )
123+ t . falsy ( out2 . plugins [ 3 ] . name === 'evalCodePlugin' )
124+ } )
125+
107126test ( 'appendPlugins option' , ( t ) => {
108127 const out = standard ( { appendPlugins : [ 'test' ] } )
109128 const out2 = standard ( { appendPlugins : 'test' } )
@@ -132,3 +151,12 @@ test('markdownPlugins option', (t) => {
132151 standardRewired ( { markdownPlugins : plugins } )
133152 undo ( )
134153} )
154+
155+ test . only ( 'integration' , ( t ) => {
156+ const markup = fs . readFileSync ( path . join ( fixtures , 'index.sgr' ) , 'utf8' )
157+ return reshape ( standard ( ) )
158+ . process ( markup )
159+ . then ( ( res ) => {
160+ t . is ( res . output ( ) . trim ( ) , '<p>wow <strong>amazing</strong></p>' )
161+ } )
162+ } )
0 commit comments