text: AJS.test.require("jira.webresources:projectpermissions",function(){"use strict";require(["jira/project/permissions/permissionmodel","jquery","wrm/context-path"],function(e,t,i){function s(){return this.context=AJS.test.mockableModuleContext(),this.AnalyticsMock={send:sinon.spy()},this.context.mock("jira/analytics",this.AnalyticsMock),this.context.mock("jira/project/permissions/grantsview",function(){var e=sinon.stub();return e.returns({el:void 0}),{render:e}}),this.context.require("jira/project/permissions/permissionrowview")}function n(t){return new e({id:112233,permissionKey:"ADMINISTER_PROJECTS",permissionName:"Administer Projects",permissionDesc:"Ability to administer a project in JIRA.",grants:[{securityType:"group",displayName:"Group",values:[{id:10004,value:"jira-administrators",displayValue:"jira-administrators"}]}],extPermission:{key:o,name:"Extended project administration",description:"If checked, project administrators will be able to edit workflows, screens, and notifications, and set default values for fields and custom fields.",endpointURI:"/rest/api/superduper-uri/attribute/"+o,checked:t}})}var o="ADMINISTER_PROJECTS.extended.enabled";module("Extended Permission - checked",{setup:function(){this.sandbox=sinon.sandbox.create(),this.model=n(!0),this.extPermission=this.model.get("extPermission");var e=s.call(this);this.view=new e({el:t("#qunit-fixture"),model:this.model}),this.view.render()},teardown:function(){this.sandbox.restore()}}),test("Should render the extended permission",function(){var e=t(this.view.el).find(".extended-permission");ok(e.length>0,"Could not locate extended-permission container"),strictEqual(e.find("label").text().trim(),this.extPermission.name),strictEqual(e.find(".description").text(),this.extPermission.description)}),test("Extended permission checkbox should be checked",function(){ok(this.view.ui.extToggle.get(0).checked)}),test("Should perform AJAX call to given endpoint",function(){var e=this.sandbox.spy(t,"ajax");this.view.ui.extToggle.click(),sinon.assert.calledOnce(e),sinon.assert.calledWithMatch(e,sinon.match.has("url",i()+this.extPermission.endpointURI)),sinon.assert.calledWithMatch(e,sinon.match.has("data",JSON.stringify(!1))),sinon.assert.calledWithMatch(e,sinon.match.has("type","PUT"))}),test("Should not perform another AJAX call when the previous is not completed yet",function(){var e=this.sandbox.spy(t,"ajax");this.view.ui.extToggle.get(0).busy=!0,this.view.ui.extToggle.click(),sinon.assert.notCalled(e)}),module("Extended Permission - unchecked",{setup:function(){this.sandbox=sinon.sandbox.create(),this.model=n(!1),this.extPermission=this.model.get("extPermission");var e=s.call(this);this.view=new e({el:t("#qunit-fixture"),model:this.model}),this.view.render()},teardown:function(){this.sandbox.restore()}}),test("Extended permission checkbox should be unchecked",function(){ok(!this.view.ui.extToggle.get(0).checked)}),test("Should perform AJAX call to given endpoint",function(){var e=this.sandbox.spy(t,"ajax");this.view.ui.extToggle.click(),sinon.assert.calledOnce(e),sinon.assert.calledWithMatch(e,sinon.match.has("url",i()+this.extPermission.endpointURI)),sinon.assert.calledWithMatch(e,sinon.match.has("data",JSON.stringify(!0))),sinon.assert.calledWithMatch(e,sinon.match.has("type","PUT"))})})});