Skip to content

Commit

Permalink
fix(examples): update jasmine karma example with best practice #122
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Nov 7, 2017
1 parent 786d3d0 commit 93cba30
Showing 1 changed file with 12 additions and 86 deletions.
98 changes: 12 additions & 86 deletions karma/jasmine/client-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
})

afterAll(function (done) {
provider.finalize()
.then(function () {
done()
}, function (err) {
done.fail(err)
})
provider.finalize().then(done, done.fail)
})

describe("sayHello", function () {
Expand All @@ -46,11 +41,7 @@
}
}
})
.then(function () {
done()
}, function (err) {
done.fail(err)
})
.then(done, done.fail)
})

it("should say hello", function (done) {
Expand All @@ -60,21 +51,8 @@
expect(JSON.parse(data.responseText)).toEqual({
reply: "Hello"
})
done()
})
.catch(function (err) {
done.fail(err)
})
})

// verify with Pact, and reset expectations
it('successfully verifies', function (done) {
provider.verify()
.then(function (a) {
done()
}, function (e) {
done.fail(e)
})
provider.verify().then(done, done.fail)
}, done.fail)
})
})

Expand Down Expand Up @@ -112,11 +90,7 @@
}
}
})
.then(function () {
done()
}, function (err) {
done.fail(err)
})
.then(done, done.fail)
})

it("should return some friends", function (done) {
Expand All @@ -128,22 +102,8 @@
name: 'Sue'
}]
})
done()
})
.catch(function (err) {
done.fail(err)
})
})

// verify with Pact, and reset expectations
// verify with Pact, and reset expectations
it('successfully verifies', function (done) {
provider.verify()
.then(function (a) {
done()
}, function (e) {
done.fail(e)
})
provider.verify().then(done, done.fail)
}, done.fail)
})
})

Expand Down Expand Up @@ -174,11 +134,7 @@
}
}
})
.then(function () {
done()
}, function (err) {
done.fail(err)
})
.then(done, done.fail)
})

it("should unfriend me", function (done) {
Expand All @@ -188,21 +144,8 @@
expect(JSON.parse(res.responseText)).toEqual({
reply: "Bye"
})
done()
})
.catch(function (err) {
done.fail(err)
})
})

// verify with Pact, and reset expectations
it('successfully verifies', function (done) {
provider.verify()
.then(function (a) {
done()
}, function (e) {
done.fail(e)
})
provider.verify().then(done, done.fail)
}, done.fail)
})
})

Expand All @@ -224,11 +167,7 @@
}
}
})
.then(function () {
done()
}, function (err) {
done.fail(err)
})
.then(done, done.fail)
})

it("returns an error message", function (done) {
Expand All @@ -238,23 +177,10 @@
}, function (e) {
expect(e.status).toEqual(404)
expect(JSON.parse(e.responseText).error).toEqual('No friends :(')
done()
provider.verify().then(done, done.fail)
})

})

// verify with Pact, and reset expectations
// verify with Pact, and reset expectations
it('successfully verifies', function (done) {
provider.verify()
.then(function (a) {
done()
}, function (e) {
done.fail(e)
})
})
})
})

})
})()

0 comments on commit 93cba30

Please sign in to comment.