test: coverage to 100%

This commit is contained in:
Harttle
2021-12-07 23:34:53 +08:00
committed by Harttle
parent 6c114267a5
commit 69286c6909
6 changed files with 62 additions and 25 deletions
+9
View File
@@ -22,5 +22,14 @@ describe('fs/loader', function () {
const candidates = [...loader.candidates('../root-dir/bar', ['/root'], '/root/current', true)]
expect(candidates).to.have.lengthOf(0)
})
it('should default `.contains()` to () => true', async function () {
const customFs = {
...fs,
contains: undefined
}
const loader = new Loader({ relativeReference: true, fs: customFs, extname: '' } as any)
const candidates = [...loader.candidates('../foo/bar', ['/root'], '/root/current', true)]
expect(candidates).to.contain('/foo/bar')
})
})
})
+22
View File
@@ -13,4 +13,26 @@ describe('TimezoneDate', () => {
expect(date.getTimezoneOffset()).to.equal(-360)
expect(date.getMinutes()).to.equal(26)
})
it('should support Date as argument', () => {
const date = new TimezoneDate(new Date('2021-10-06T14:26:00.000+08:00'), 0)
expect(date.getHours()).to.equal(6)
})
it('should support .getMilliseconds()', () => {
const date = new TimezoneDate('2021-10-06T14:26:00.001+00:00', 0)
expect(date.getMilliseconds()).to.equal(1)
})
it('should support .getDay()', () => {
const date = new TimezoneDate('2021-12-07T00:00:00.001+08:00', -480)
expect(date.getDay()).to.equal(2)
})
it('should support .toLocaleTimeString()', () => {
const date = new TimezoneDate('2021-10-06T00:00:00.001+00:00', -480)
expect(date.toLocaleTimeString('en-US')).to.equal('8:00:00 AM')
expect(() => date.toLocaleDateString()).to.not.throw()
})
it('should support .toLocaleDateString()', () => {
const date = new TimezoneDate('2021-10-06T22:00:00.001+00:00', -480)
expect(date.toLocaleDateString('en-US')).to.equal('10/7/2021')
expect(() => date.toLocaleDateString()).to.not.throw()
})
})