Skip to content

Commit

Permalink
🎨 grab file contents in beforeEach
Browse files Browse the repository at this point in the history
Co-authored-by: evelyn masso <[email protected]>
  • Loading branch information
kuychaco and outofambit committed Aug 12, 2019
1 parent 774bd36 commit cc359d0
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions app/test/unit/git/commit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,28 @@ describe('git/commit', () => {
})

describe('binary file conflicts', () => {
let fileName: string
let fileContentsOurs: string, fileContentsTheirs: string
beforeEach(async () => {
const path = await setupFixtureRepository(
const repoPath = await setupFixtureRepository(
'detect-conflict-in-binary-file'
)
repository = new Repository(path, -1, null, false)
await GitProcess.exec(['checkout', 'make-a-change'], repository.path)
repository = new Repository(repoPath, -1, null, false)
fileName = 'my-cool-image.png'

await GitProcess.exec(['checkout', 'master'], repoPath)

fileContentsTheirs = await FSE.readFile(
path.join(repoPath, fileName),
'utf8'
)

await GitProcess.exec(['checkout', 'make-a-change'], repoPath)

fileContentsOurs = await FSE.readFile(
path.join(repoPath, fileName),
'utf8'
)
})

it('chooses `their` version of a file and commits', async () => {
Expand All @@ -603,11 +619,6 @@ describe('git/commit', () => {
isConflictedFile(file.status) && isManualConflict(file.status)
).toBe(true)

const fileContentsOurs = await FSE.readFile(
path.join(repository.path, file.path),
'utf8'
)

const trackedFiles = files.filter(
f => f.status.kind !== AppFileStatusKind.Untracked
)
Expand All @@ -623,14 +634,6 @@ describe('git/commit', () => {
)

expect(fileContents).not.toStrictEqual(fileContentsOurs)

await GitProcess.exec(['checkout', 'master'], repo.path)

const fileContentsTheirs = await FSE.readFile(
path.join(repository.path, file.path),
'utf8'
)

expect(fileContents).toStrictEqual(fileContentsTheirs)
})

Expand All @@ -649,11 +652,6 @@ describe('git/commit', () => {
isConflictedFile(file.status) && isManualConflict(file.status)
).toBe(true)

const fileContentsOurs = await FSE.readFile(
path.join(repository.path, file.path),
'utf8'
)

const trackedFiles = files.filter(
f => f.status.kind !== AppFileStatusKind.Untracked
)
Expand Down

0 comments on commit cc359d0

Please sign in to comment.