mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-01 03:03:09 +03:00
af8ecef30d
Remove 'Async' from Project's asynchronous open methods
52 lines
2.2 KiB
CoffeeScript
52 lines
2.2 KiB
CoffeeScript
path = require 'path'
|
|
{Site} = require 'telepath'
|
|
Project = require '../src/project'
|
|
Git = require '../src/git'
|
|
|
|
describe "Project replication", ->
|
|
[doc1, doc2, project1, project2] = []
|
|
|
|
beforeEach ->
|
|
# pretend that home-1/project and home-2/project map to the same git repository url
|
|
spyOn(Git, 'open').andReturn
|
|
getOriginUrl: -> 'git://server/project.git'
|
|
destroy: ->
|
|
|
|
projectHome1 = path.join(__dirname, 'fixtures', 'replication', 'home-1')
|
|
projectHome2 = path.join(__dirname, 'fixtures', 'replication', 'home-2')
|
|
config.set('core.projectHome', projectHome1)
|
|
project1 = new Project(path.join(projectHome1, 'project'))
|
|
project1.bufferForPathSync('file-1.txt')
|
|
project1.bufferForPathSync('file-1.txt')
|
|
expect(project1.getBuffers().length).toBe 1
|
|
|
|
doc1 = project1.getState()
|
|
doc2 = doc1.clone(new Site(2))
|
|
connection = doc1.connect(doc2)
|
|
|
|
# pretend we're bootstrapping a joining window
|
|
config.set('core.projectHome', projectHome2)
|
|
project2 = deserialize(doc2)
|
|
|
|
afterEach ->
|
|
project1.destroy()
|
|
project2.destroy()
|
|
|
|
it "replicates the initial path and open buffers of the project", ->
|
|
expect(project2.getPath()).not.toBe project1.getPath()
|
|
expect(project2.getBuffers().length).toBe 1
|
|
expect(project2.getBuffers()[0].getRelativePath()).toBe project1.getBuffers()[0].getRelativePath()
|
|
expect(project2.getBuffers()[0].getPath()).not.toBe project1.getBuffers()[0].getPath()
|
|
|
|
it "replicates insertion and removal of open buffers", ->
|
|
project2.bufferForPathSync('file-2.txt')
|
|
expect(project1.getBuffers().length).toBe 2
|
|
expect(project2.getBuffers()[0].getRelativePath()).toBe project1.getBuffers()[0].getRelativePath()
|
|
expect(project2.getBuffers()[1].getRelativePath()).toBe project1.getBuffers()[1].getRelativePath()
|
|
expect(project2.getBuffers()[0].getRelativePath()).not.toBe project1.getBuffers()[0].getPath()
|
|
expect(project2.getBuffers()[1].getRelativePath()).not.toBe project1.getBuffers()[1].getPath()
|
|
|
|
project1.removeBuffer(project1.bufferForPathSync('file-2.txt'))
|
|
expect(project1.getBuffers().length).toBe 1
|
|
expect(project2.getBuffers()[0].getRelativePath()).toBe project1.getBuffers()[0].getRelativePath()
|