Skip to content

Commit

Permalink
test(product-sync): catch errors and fail fast in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lojzatran committed Mar 14, 2017
1 parent 4f4d144 commit eba94d9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/spec/integration/subscriptions.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@ newSubscription =

describe 'Integration Subscriptions', ->

beforeEach (done) ->
beforeEach () ->
@client = new SphereClient config: Config
done()

afterEach (done) ->
debug 'Removing all subscriptions'
@client.subscriptions.all().fetch()
.then (response) =>
Promise.map(response.body.results, (sub) =>
@client.subscriptions.byId(sub.id).delete(sub.version)
)
, { concurrency: 10 })
.then () ->
done()
.catch (error) -> done(_.prettify(error))

it 'should create subscription', (done) ->
@client.subscriptions.save(newSubscription)
.then (response) =>
expect(response.statusCode).toBe 201
expect(response.body.id).toBeDefined()
done()
.catch (error) -> done(_.prettify(error))
, 20000

it 'should update message subscriptions', (done) ->
Expand All @@ -57,6 +58,7 @@ describe 'Integration Subscriptions', ->
expect(response.body.messages[0].resourceTypeId).toBe 'cart'
expect(response.body.messages[0].types.length).toBe 0
done()
.catch (error) -> done(_.prettify(error))
, 20000

it 'should delete subscription by key', (done) ->
Expand All @@ -69,3 +71,4 @@ describe 'Integration Subscriptions', ->
.then (response) =>
expect(response.body.total).toBe 0
done()
.catch (error) -> done(_.prettify(error))

0 comments on commit eba94d9

Please sign in to comment.