
301
レシピ 9.2 モジュールのモックアップを作成する
test/index.js(続き)
mp3dat.stat(testFile, function(err, stats) {
should.ifError(err);
//
プロパティの存在判定
stats.should.have.property('duration');
stats.should.have.property('bitrate');
stats.should.have.property('filesize');
stats.should.have.property('timestamp');
stats.should.have.property('timesig');
//
プロパティの
type
判定
stats.duration.should.be.an.instanceof(Object);
stats.bitrate.should.be.a('number');
stats.filesize.should.be.a('number');
stats.timestamp.should.be.a('number');
stats.timesig.should.match(/^\d+:\d+:\d+$/);
// duration
プロパティの各値の存在判定
stats.duration.should.have.keys('hours', 'minutes', 'seconds', 'milliseconds'); ...