Skip to content

Commit

Permalink
Fixed #45
Browse files Browse the repository at this point in the history
Fixed #49
  • Loading branch information
claustres committed Mar 13, 2020
1 parent 9b4f8ea commit 1649e3f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const isDiscoveredService = (app, serviceDescriptor) => {
}

function publishService (app, path) {
// App not yet initialized, publishing will occur again once done
if (!app.servicePublisher) return
const service = app.service(path)
if (!service || (typeof service !== 'object')) return
if (service.remote) {
Expand Down
70 changes: 36 additions & 34 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('feathers-distributed', () => {
}
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('initiate the socket clients', () => {
for (let i = 0; i < nbApps; i++) {
Expand All @@ -231,57 +231,57 @@ describe('feathers-distributed', () => {
}
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('ensure middleware can been called on app', async () => {
const url = 'http://localhost:' + (8080 + gateway) + '/middleware'
await request.get(url)
expect(appMiddleware).to.have.been.called()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch find rest service calls from remote to local without auth', async () => {
const users = await restClientServices[service1].find({})
expect(users.length > 0).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch get rest service calls from remote to local without auth', async () => {
const user = await restClientServices[service1].get(1)
expect(user.id === 1).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch create rest service calls from remote to local without auth', async () => {
const user = await restClientServices[service1].create({ name: 'Donald Doe' })
expect(user.id === startId).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch update rest service calls from remote to local without auth', async () => {
const user = await restClientServices[service1].update(startId, { name: 'Donald Dover' })
expect(user.name === 'Donald Dover').beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch patch rest service calls from remote to local without auth', async () => {
const user = await restClientServices[service1].patch(startId, { name: 'Donald Doe' })
expect(user.name === 'Donald Doe').beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch remove rest service calls from remote to local without auth', async () => {
const user = await restClientServices[service1].remove(startId)
expect(user.id === startId).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('ensure distribution hooks have been called on remote service', () => {
expect(beforeHook).to.have.been.called()
Expand All @@ -303,14 +303,14 @@ describe('feathers-distributed', () => {
expect(users.length > 0).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch get socket service calls from remote to local without auth', async () => {
const user = await socketClientServices[service1].get(1)
expect(user.id === 1).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch create socket service calls from remote to local without auth', async () => {
// Jump to next user
Expand All @@ -319,40 +319,42 @@ describe('feathers-distributed', () => {
expect(user.id === startId).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch update socket service calls from remote to local without auth', async () => {
const user = await socketClientServices[service1].update(startId, { name: 'Donald Dover' })
expect(user.name === 'Donald Dover').beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch patch socket service calls from remote to local without auth', async () => {
const user = await socketClientServices[service1].patch(startId, { name: 'Donald Doe' })
expect(user.name === 'Donald Doe').beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch remove socket service calls from remote to local without auth', async () => {
const user = await socketClientServices[service1].remove(startId)
expect(user.id === startId).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch create socket service events from local to remote without auth', done => {
// Jump to next user
startId += 1
socketClientServices[service2].once('created', user => {
console.log(user)
expect(user.name === 'Donald Doe').beTrue()
expect(user.id === startId).beTrue()
done()
})
socketClientServices[gateway].create({ name: 'Donald Doe' })
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch update socket service events from local to remote without auth', done => {
socketClientServices[service2].once('updated', user => {
Expand All @@ -362,7 +364,7 @@ describe('feathers-distributed', () => {
socketClientServices[gateway].update(startId, { name: 'Donald Dover' })
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch patch socket service events from local to remote without auth', done => {
socketClientServices[service2].once('patched', user => {
Expand All @@ -372,7 +374,7 @@ describe('feathers-distributed', () => {
socketClientServices[gateway].patch(startId, { name: 'Donald Doe' })
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch remove socket service events from local to remote without auth', done => {
socketClientServices[service2].once('removed', user => {
Expand All @@ -382,7 +384,7 @@ describe('feathers-distributed', () => {
socketClientServices[gateway].remove(startId)
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dynamically register a custom service', async () => {
const customService = memory()
Expand Down Expand Up @@ -565,14 +567,14 @@ describe('feathers-distributed', () => {
expect(users.length > 0).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch get rest service calls from remote to local with auth', async () => {
const user = await restClientServices[service1].get(1)
expect(user.id === 1).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch create rest service calls from remote to local with auth', async () => {
// Jump to next user
Expand All @@ -581,21 +583,21 @@ describe('feathers-distributed', () => {
expect(user.id === startId).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch update rest service calls from remote to local with auth', async () => {
const user = await restClientServices[service1].update(startId, { name: 'Donald Dover' })
expect(user.name === 'Donald Dover').beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch patch rest service calls from remote to local with auth', async () => {
const user = await restClientServices[service1].patch(startId, { name: 'Donald Doe' })
expect(user.name === 'Donald Doe').beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch remove rest service calls from remote to local with auth', async () => {
const user = await restClientServices[service1].remove(startId)
Expand All @@ -609,14 +611,14 @@ describe('feathers-distributed', () => {
expect(users.length > 0).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch get socket service calls from remote to local with auth', async () => {
const user = await socketClientServices[service1].get(1)
expect(user.id === 1).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch create socket service calls from remote to local with auth', async () => {
// Jump to next user
Expand All @@ -625,28 +627,28 @@ describe('feathers-distributed', () => {
expect(user.id === startId).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch update socket service calls from remote to local with auth', async () => {
const user = await socketClientServices[service1].update(startId, { name: 'Donald Dover' })
expect(user.name === 'Donald Dover').beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch patch socket service calls from remote to local with auth', async () => {
const user = await socketClientServices[service1].patch(startId, { name: 'Donald Doe' })
expect(user.name === 'Donald Doe').beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch remove socket service calls from remote to local with auth', async () => {
const user = await socketClientServices[service1].remove(startId)
expect(user.id === startId).beTrue()
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch create socket service events from local to remote with auth', done => {
// Jump to next user
Expand All @@ -658,7 +660,7 @@ describe('feathers-distributed', () => {
socketClientServices[gateway].create({ name: 'Donald Doe' })
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch update socket service events from local to remote with auth', done => {
socketClientServices[service2].once('updated', user => {
Expand All @@ -668,7 +670,7 @@ describe('feathers-distributed', () => {
socketClientServices[gateway].update(startId, { name: 'Donald Dover' })
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch patch socket service events from local to remote with auth', done => {
socketClientServices[service2].once('patched', user => {
Expand All @@ -678,7 +680,7 @@ describe('feathers-distributed', () => {
socketClientServices[gateway].patch(startId, { name: 'Donald Doe' })
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('dispatch remove socket service events from local to remote with auth', done => {
socketClientServices[service2].once('removed', user => {
Expand All @@ -688,7 +690,7 @@ describe('feathers-distributed', () => {
socketClientServices[gateway].remove(startId)
})
// Let enough time to process
.timeout(5000)
.timeout(10000)

it('disable events publishing globally', () => {
expect(apps[gateway].serviceEventsPublisher).toExist()
Expand Down

0 comments on commit 1649e3f

Please sign in to comment.