|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +const fs = require("fs"); |
| 4 | +const { expect } = require("chai"); |
| 5 | + |
| 6 | +module.exports = isStats; |
| 7 | + |
| 8 | +/** |
| 9 | + * Assets that the given objects is a Readdir Enhanced Stats object. |
| 10 | + */ |
| 11 | +function isStats (stats) { |
| 12 | + expect(stats).to.be.an("object").and.instanceOf(fs.Stats); |
| 13 | + expect(stats.atime).to.be.an.instanceOf(Date); |
| 14 | + expect(stats.atimeMs).to.be.a("number").above(0); |
| 15 | + expect(stats.birthtime).to.be.an.instanceOf(Date); |
| 16 | + expect(stats.birthtimeMs).to.be.a("number").above(0); |
| 17 | + expect(stats.blksize).to.be.a("number").above(0); |
| 18 | + expect(stats.blocks).to.be.a("number").at.least(0); |
| 19 | + expect(stats.ctime).to.be.an.instanceOf(Date); |
| 20 | + expect(stats.ctimeMs).to.be.a("number").above(0); |
| 21 | + expect(stats.depth).to.be.a("number").at.least(0); |
| 22 | + expect(stats.dev).to.be.a("number").above(0); |
| 23 | + expect(stats.gid).to.be.a("number").at.least(0); |
| 24 | + expect(stats.ino).to.be.a("number").above(0); |
| 25 | + expect(stats.mode).to.be.a("number").above(0); |
| 26 | + expect(stats.mtime).to.be.an.instanceOf(Date); |
| 27 | + expect(stats.mtimeMs).to.be.a("number").above(0); |
| 28 | + expect(stats.nlink).to.be.a("number").above(0); |
| 29 | + expect(stats.path).to.be.a("string").with.length.above(0); |
| 30 | + expect(stats.rdev).to.be.a("number").at.least(0); |
| 31 | + expect(stats.size).to.be.a("number").at.least(0); |
| 32 | + expect(stats.uid).to.be.a("number").at.least(0); |
| 33 | + |
| 34 | + return true; |
| 35 | +} |
0 commit comments