Skip to content

Commit c2beec8

Browse files
committed
fix tests for invalid dates
1 parent 97ff9ce commit c2beec8

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

test/dest.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -666,25 +666,24 @@ describe('dest stream', function() {
666666
var expectedContents = fs.readFileSync(inputPath);
667667
var expectedCwd = __dirname;
668668
var expectedBase = path.join(__dirname, './out-fixtures');
669-
var expectedMtime = new Date('foo');
669+
var expectedMtime = new Date();
670+
var invalidMtime = new Date(undefined);
670671

671672
var expectedFile = new File({
672673
base: inputBase,
673674
cwd: __dirname,
674675
path: inputPath,
675676
contents: expectedContents,
676677
stat: {
677-
mtime: expectedMtime
678+
mtime: invalidMtime
678679
}
679680
});
680681

681682
var onEnd = function(){
682683
buffered.length.should.equal(1);
683684
buffered[0].should.equal(expectedFile);
684685
fs.existsSync(expectedPath).should.equal(true);
685-
expectedFile.stat.should.have.property('mtime');
686-
expectedFile.stat.mtime.should.equal(expectedMtime);
687-
expectedFile.stat.should.not.have.property('atime');
686+
fs.lstatSync(expectedPath).mtime.setMilliseconds(0).should.equal(expectedMtime.setMilliseconds(0));
688687
done();
689688
};
690689

@@ -705,16 +704,17 @@ describe('dest stream', function() {
705704
var expectedContents = fs.readFileSync(inputPath);
706705
var expectedCwd = __dirname;
707706
var expectedBase = path.join(__dirname, './out-fixtures');
708-
var expectedAtime = new Date('foo');
709-
var expectedMtime = fs.lstatSync(inputPath).mtime;
707+
var expectedAtime = new Date();
708+
var expectedMtime = new Date();
709+
var invalidAtime = new Date(undefined);
710710

711711
var expectedFile = new File({
712712
base: inputBase,
713713
cwd: __dirname,
714714
path: inputPath,
715715
contents: expectedContents,
716716
stat: {
717-
atime: expectedAtime,
717+
atime: invalidAtime,
718718
mtime: expectedMtime
719719
}
720720
});
@@ -723,10 +723,8 @@ describe('dest stream', function() {
723723
buffered.length.should.equal(1);
724724
buffered[0].should.equal(expectedFile);
725725
fs.existsSync(expectedPath).should.equal(true);
726-
expectedFile.stat.should.have.property('mtime');
727-
expectedFile.stat.mtime.should.equal(expectedMtime);
728-
expectedFile.stat.should.have.property('atime');
729-
expectedFile.stat.atime.should.equal(expectedAtime);
726+
fs.lstatSync(expectedPath).atime.setMilliseconds(0).should.equal(expectedAtime.setMilliseconds(0));
727+
fs.lstatSync(expectedPath).mtime.setMilliseconds(0).should.equal(expectedMtime.setMilliseconds(0));
730728
done();
731729
};
732730

0 commit comments

Comments
 (0)