diff --git a/__tests__/__fixtures__/test-GitIndex-timestamp/nano.txt b/__tests__/__fixtures__/test-GitIndex-timestamp/nano.txt new file mode 100644 index 000000000..00a1ba6b2 --- /dev/null +++ b/__tests__/__fixtures__/test-GitIndex-timestamp/nano.txt @@ -0,0 +1 @@ +validate nanoseconds \ No newline at end of file diff --git a/__tests__/test-GitIndex.js b/__tests__/test-GitIndex.js index 3520d2cf1..c4393cf46 100644 --- a/__tests__/test-GitIndex.js +++ b/__tests__/test-GitIndex.js @@ -2,7 +2,13 @@ const path = require('path') -const { GitIndex, GitIndexManager } = require('isomorphic-git/internal-apis') +const { + GitIndex, + GitIndexManager, + FileSystem, +} = require('isomorphic-git/internal-apis') + +const { normalizeStats } = require('../src/utils/normalizeStats.js') const { makeFixture } = require('./__helpers__/FixtureFS.js') @@ -128,4 +134,29 @@ describe('GitIndex', () => { expect(ctimeSeconds).not.toBeNull() expect(ctimeNanoseconds).not.toBeNull() }) + ;(process.browser ? xit : it)( + 'ensure nanoseconds of files are equal with index', + async () => { + const _fs = Object.assign({}, require('fs')) + const fs = new FileSystem(_fs) + + const buffer = await fs.read(path.join('.git/index')) + const index = await GitIndex.from(buffer) + const file = '__tests__/__fixtures__/test-GitIndex-timestamp/nano.txt' + + const stats = normalizeStats(await fs.lstat(file)) + expect(index.entriesMap.get(file).ctimeSeconds).toEqual( + stats.ctimeSeconds + ) + expect(index.entriesMap.get(file).ctimeNanoseconds).toEqual( + stats.ctimeNanoseconds + ) + expect(index.entriesMap.get(file).mtimeSeconds).toEqual( + stats.mtimeSeconds + ) + expect(index.entriesMap.get(file).mtimeNanoseconds).toEqual( + stats.mtimeNanoseconds + ) + } + ) })