diff --git a/public/app/features/org/specs/team_details_ctrl.jest.ts b/public/app/features/org/specs/team_details_ctrl.jest.ts new file mode 100644 index 000000000000..c636de7ec564 --- /dev/null +++ b/public/app/features/org/specs/team_details_ctrl.jest.ts @@ -0,0 +1,42 @@ +import '../team_details_ctrl'; +import TeamDetailsCtrl from '../team_details_ctrl'; + +describe('TeamDetailsCtrl', () => { + var backendSrv = { + searchUsers: jest.fn(() => Promise.resolve([])), + get: jest.fn(() => Promise.resolve([])), + post: jest.fn(() => Promise.resolve([])), + }; + + //Team id + var routeParams = { + id: 1, + }; + + var navModelSrv = { + getNav: jest.fn(), + }; + + var teamDetailsCtrl = new TeamDetailsCtrl({ $broadcast: jest.fn() }, backendSrv, routeParams, navModelSrv); + + describe('when user is chosen to be added to team', () => { + beforeEach(() => { + teamDetailsCtrl = new TeamDetailsCtrl({ $broadcast: jest.fn() }, backendSrv, routeParams, navModelSrv); + const userItem = { + id: 2, + login: 'user2', + }; + teamDetailsCtrl.userPicked(userItem); + }); + + it('should parse the result and save to db', () => { + expect(backendSrv.post.mock.calls[0][0]).toBe('/api/teams/1/members'); + expect(backendSrv.post.mock.calls[0][1].userId).toBe(2); + }); + + it('should refresh the list after saving.', () => { + expect(backendSrv.get.mock.calls[0][0]).toBe('/api/teams/1'); + expect(backendSrv.get.mock.calls[1][0]).toBe('/api/teams/1/members'); + }); + }); +}); diff --git a/public/app/features/org/specs/team_details_ctrl_specs.ts b/public/app/features/org/specs/team_details_ctrl_specs.ts deleted file mode 100644 index 347f3796170c..000000000000 --- a/public/app/features/org/specs/team_details_ctrl_specs.ts +++ /dev/null @@ -1,48 +0,0 @@ -import '../team_details_ctrl'; -import { describe, beforeEach, it, expect, sinon, angularMocks } from 'test/lib/common'; -import TeamDetailsCtrl from '../team_details_ctrl'; - -describe('TeamDetailsCtrl', () => { - var ctx: any = {}; - var backendSrv = { - searchUsers: sinon.stub().returns(Promise.resolve([])), - get: sinon.stub().returns(Promise.resolve([])), - post: sinon.stub().returns(Promise.resolve([])), - }; - - beforeEach(angularMocks.module('grafana.core')); - beforeEach(angularMocks.module('grafana.controllers')); - - beforeEach( - angularMocks.inject(($rootScope, $controller, $q) => { - ctx.$q = $q; - ctx.scope = $rootScope.$new(); - ctx.ctrl = $controller(TeamDetailsCtrl, { - $scope: ctx.scope, - backendSrv: backendSrv, - $routeParams: { id: 1 }, - navModelSrv: { getNav: sinon.stub() }, - }); - }) - ); - - describe('when user is chosen to be added to team', () => { - beforeEach(() => { - const userItem = { - id: 2, - login: 'user2', - }; - ctx.ctrl.userPicked(userItem); - }); - - it('should parse the result and save to db', () => { - expect(backendSrv.post.getCall(0).args[0]).to.eql('/api/teams/1/members'); - expect(backendSrv.post.getCall(0).args[1].userId).to.eql(2); - }); - - it('should refresh the list after saving.', () => { - expect(backendSrv.get.getCall(0).args[0]).to.eql('/api/teams/1'); - expect(backendSrv.get.getCall(1).args[0]).to.eql('/api/teams/1/members'); - }); - }); -});