Skip to content

Commit

Permalink
Remove sinon dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetitcolas committed Sep 11, 2015
1 parent 2520860 commit 2dadf40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"rangy": "^1.3.0",
"restangular": "^1.5.1",
"sass-loader": "^0.5.0",
"sinon": "1.14.1",
"style-loader": "^0.12.2",
"superagent": "^0.18.2",
"textangular": "^1.3.11",
Expand Down
30 changes: 10 additions & 20 deletions src/javascripts/test/unit/Crud/delete/DeleteControllerSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var sinon = require('sinon');

describe('DeleteController', function () {
'use strict';

Expand All @@ -13,11 +11,13 @@ describe('DeleteController', function () {
$window = _$window_;
$q = _$q_;
$state = {
go: sinon.spy(),
get: sinon.spy(),
go: jasmine.createSpy('$state.go'),
get: jasmine.createSpy('$state.get'),
params: {}
};
writeQueries = { deleteOne: () => {} };
writeQueries = {
deleteOne: jasmine.createSpy('writeQueries.deleteOne').and.callFake(() => $q.when())
};
notification = humane;
params = {
id: 3,
Expand All @@ -34,12 +34,6 @@ describe('DeleteController', function () {

describe('deleteOne', function() {
describe('on success', function() {
let writeQueries;
beforeEach(inject(function($q) {
writeQueries = { deleteOne: sinon.stub() };
writeQueries.deleteOne.returns($q.when());
}));

it('should delete given entity', function(done) {
// assume we are on post #3 deletion page
const entity = new Entity('post');
Expand All @@ -57,7 +51,7 @@ describe('DeleteController', function () {
}, view, entry);

deleteController.deleteOne(view, 3).then(function() {
expect(writeQueries.deleteOne.calledOnce).toBeTruthy();
expect(writeQueries.deleteOne).toHaveBeenCalled();
done();
}, done);

Expand All @@ -84,8 +78,8 @@ describe('DeleteController', function () {
}, view, entry);

deleteController.deleteOne(view, 3).then(function() {
expect($state.get.firstCall.args[0]).toBe('list');
expect($state.go.firstCall.args[1]).toEqual({
expect($state.get.calls.argsFor(0)[0]).toBe('list');
expect($state.go.calls.argsFor(0)[1]).toEqual({
entity: 'post'
});
done();
Expand All @@ -108,14 +102,14 @@ describe('DeleteController', function () {
getEntity: () => new Entity('comment')
};

let $window = { history: { back: sinon.spy() } };
let $window = { history: { back: jasmine.createSpy('$window.history.back') } };
let deleteController = new DeleteController($scope, $window, $state, $q, writeQueries, notification, {
id: commentId,
entity: 'comment'
}, view, entry);

deleteController.deleteOne(view, 3).then(function() {
expect($window.history.back.calledOnce).toBe(true);
expect($window.history.back).toHaveBeenCalled();
done();
}, done);

Expand All @@ -125,10 +119,6 @@ describe('DeleteController', function () {

$scope.$digest();
});

afterEach(function() {
sinon.restore();
});
});
});
});

0 comments on commit 2dadf40

Please sign in to comment.