@@ -2072,6 +2072,68 @@ describe('File', function() {
20722072 } ) ;
20732073 } ) ;
20742074
2075+ describe ( 'save' , function ( ) {
2076+ var DATA = 'Data!' ;
2077+
2078+ it ( 'should accept an options object' , function ( done ) {
2079+ var options = { } ;
2080+
2081+ file . createWriteStream = function ( options_ ) {
2082+ assert . strictEqual ( options_ , options ) ;
2083+ setImmediate ( done ) ;
2084+ return new stream . PassThrough ( ) ;
2085+ } ;
2086+
2087+ file . save ( DATA , options , assert . ifError ) ;
2088+ } ) ;
2089+
2090+ it ( 'should not require options' , function ( done ) {
2091+ file . createWriteStream = function ( options_ ) {
2092+ assert . deepEqual ( options_ , { } ) ;
2093+ setImmediate ( done ) ;
2094+ return new stream . PassThrough ( ) ;
2095+ } ;
2096+
2097+ file . save ( DATA , assert . ifError ) ;
2098+ } ) ;
2099+
2100+ it ( 'should register the error listener' , function ( done ) {
2101+ file . createWriteStream = function ( ) {
2102+ var writeStream = new stream . PassThrough ( ) ;
2103+ writeStream . on ( 'error' , done ) ;
2104+ setImmediate ( function ( ) {
2105+ writeStream . emit ( 'error' ) ;
2106+ } ) ;
2107+ return writeStream ;
2108+ } ;
2109+
2110+ file . save ( DATA , assert . ifError ) ;
2111+ } ) ;
2112+
2113+ it ( 'should register the finish listener' , function ( done ) {
2114+ file . createWriteStream = function ( ) {
2115+ var writeStream = new stream . PassThrough ( ) ;
2116+ writeStream . once ( 'finish' , done ) ;
2117+ return writeStream ;
2118+ } ;
2119+
2120+ file . save ( DATA , assert . ifError ) ;
2121+ } ) ;
2122+
2123+ it ( 'should write the data' , function ( done ) {
2124+ file . createWriteStream = function ( ) {
2125+ var writeStream = new stream . PassThrough ( ) ;
2126+ writeStream . on ( 'data' , function ( data ) {
2127+ assert . strictEqual ( data . toString ( ) , DATA ) ;
2128+ done ( ) ;
2129+ } ) ;
2130+ return writeStream ;
2131+ } ;
2132+
2133+ file . save ( DATA , assert . ifError ) ;
2134+ } ) ;
2135+ } ) ;
2136+
20752137 describe ( 'startResumableUpload_' , function ( ) {
20762138 describe ( 'starting' , function ( ) {
20772139 it ( 'should start a resumable upload' , function ( done ) {
0 commit comments