From fafae1e8626571fdb1fdbd1a25dcb5f4fdb117d7 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 30 Sep 2015 16:22:18 +0200 Subject: [PATCH] add web tests --- .../tests/apps/permission-templates-test.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/server/sonar-web/tests/apps/permission-templates-test.js b/server/sonar-web/tests/apps/permission-templates-test.js index d7cc02fdf8b..b79adde98a5 100644 --- a/server/sonar-web/tests/apps/permission-templates-test.js +++ b/server/sonar-web/tests/apps/permission-templates-test.js @@ -4,8 +4,8 @@ import Defaults from '../../src/main/js/apps/permission-templates/permission-tem import SetDefaults from '../../src/main/js/apps/permission-templates/permission-template-set-defaults'; let TestUtils = React.addons.TestUtils; -let chai = require('chai'); -let expect = chai.expect; +let expect = require('chai').expect; +let sinon = require('sinon'); describe('Permission Templates', function () { describe('Defaults', () => { @@ -29,6 +29,16 @@ describe('Permission Templates', function () { expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-qualifier-vw')).to.have.length(1); }); + it('should not display qualifiers', () => { + let permissionTemplate = { defaultFor: [] }, + topQualifiers = ['TRK', 'VW']; + let result = TestUtils.renderIntoDocument( + + ); + expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-qualifier-trk')).to.be.empty; + expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-qualifier-vw')).to.be.empty; + }); + it('should omit "project" if there is only one qualifier', () => { let permissionTemplate = { defaultFor: ['TRK'] }, topQualifiers = ['TRK']; @@ -40,7 +50,7 @@ describe('Permission Templates', function () { }); describe('SetDefaults', () => { - var refresh = function () {}; + var refresh = sinon.spy(); it('should display a dropdown with one option', () => { let permissionTemplate = { defaultFor: ['VW'] }, -- 2.39.5