Skip to content

Commit 080898f

Browse files
committed
fix(test): fix logic issue in karma tests that was passing for the wrong reasons
1 parent 499ec8c commit 080898f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

karma/jasmine/client-spec.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696

9797
describe("unfriendMe", function () {
9898

99+
afterEach(function () {
100+
return provider.removeInteractions()
101+
})
102+
99103
describe("when I have some friends", function () {
100104

101105
beforeAll(function (done) {
@@ -139,11 +143,12 @@
139143
state: 'I have no friends',
140144
uponReceiving: 'a request to unfriend',
141145
withRequest: {
142-
method: 'put',
146+
method: 'PUT',
143147
path: '/unfriendMe'
144148
},
145149
willRespondWith: {
146-
status: 404
150+
status: 404,
151+
body: { error: "No friends :(" }
147152
}
148153
})
149154
.then(function () { done() }, function (err) { done.fail(err) })
@@ -154,6 +159,8 @@
154159
client.unfriendMe().then(function() {
155160
done(new Error('expected request to /unfriend me to fail'))
156161
}, function(e) {
162+
expect(e.status).toEqual(404)
163+
expect(JSON.parse(e.responseText).error).toEqual('No friends :(')
157164
done()
158165
})
159166

karma/mocha/client-spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696

9797
describe("unfriendMe", function () {
9898

99+
afterEach(function() {
100+
return provider.removeInteractions()
101+
})
102+
99103
describe("when I have some friends", function () {
100104

101105
before(function (done) {
@@ -139,11 +143,12 @@
139143
state: 'I have no friends',
140144
uponReceiving: 'a request to unfriend',
141145
withRequest: {
142-
method: 'put',
146+
method: 'PUT',
143147
path: '/unfriendMe'
144148
},
145149
willRespondWith: {
146-
status: 404
150+
status: 404,
151+
body: {}
147152
}
148153
})
149154
.then(function () { done() }, function (err) { done(err) })
@@ -154,6 +159,7 @@
154159
client.unfriendMe().then(function() {
155160
done(new Error('expected request to /unfriend me to fail'))
156161
}, function(e) {
162+
expect(e).to.eql('No friends :(')
157163
done()
158164
})
159165

0 commit comments

Comments
 (0)