11var assert = require ( 'assert' ) ,
2+ exec = require ( 'child_process' ) . exec ,
3+ fs = require ( 'fs' ) ,
24 Extension = require ( 'openframe-extension' ) ,
35 WebsiteExtension = require ( '../extension' ) ;
46
@@ -9,6 +11,14 @@ describe('instantiation', function() {
911} ) ;
1012
1113describe ( 'properties' , function ( ) {
14+ before ( function ( done ) {
15+ exec ( 'cp ' + __dirname + '/.xinitrc.spec ' + __dirname + '/.xinitrc' , done ) ;
16+ } ) ;
17+
18+ after ( function ( done ) {
19+ exec ( 'rm ' + __dirname + '/.xinitrc' , done ) ;
20+ } ) ;
21+
1222 it ( 'should include all required format properties' , function ( ) {
1323 var format = WebsiteExtension . props . format ;
1424
@@ -31,4 +41,26 @@ describe('properties', function() {
3141 assert ( format . end_command ) ;
3242 assert ( typeof format . end_command === 'string' ) ;
3343 } ) ;
44+
45+ it ( 'start_command should update .xinitrc file with supplied token' , function ( done ) {
46+ var format = WebsiteExtension . props . format ,
47+ command ,
48+ expected = 'exec /usr/bin/chromium --noerrdialogs --kiosk --incognito http://test.com' ;
49+
50+ // use test .xinitrc
51+ format . xinitrcPath = __dirname + '/.xinitrc' ;
52+
53+ // replace $url token with url string
54+ command = format . start_command ( { } , {
55+ $url : 'http://test.com'
56+ } ) ;
57+
58+ assert ( typeof command === 'string' ) ;
59+
60+ fs . readFile ( format . xinitrcPath , 'utf8' , function ( err , data ) {
61+ if ( err ) throw err ;
62+ assert . equal ( data , expected ) ;
63+ done ( ) ;
64+ } ) ;
65+ } ) ;
3466} ) ;
0 commit comments