define(function (require) { var bdd = require('intern!bdd'); var assert = require('intern/chai!assert'); var helper = require('build/js/components/source-viewer/helpers/code-with-issue-locations-helper'); bdd.describe('Code With Issue Locations Helper', function () { bdd.it('should exist', function () { assert.equal(typeof helper, 'function'); }); bdd.it('should mark one location', function () { var code = 'if (a + 1) {', locations = [{ from: 1, to: 5 }], result = helper(code, locations, 'x'); assert.equal(result, 'if (a + 1) {'); }); bdd.it('should mark two locations', function () { var code = 'abcdefghijklmnopqrst', locations = [ { from: 1, to: 6 }, { from: 11, to: 16 } ], result = helper(code, locations, 'x'); assert.equal(result, ['a', 'bcdef', 'ghijk', 'lmnop', 'qrst'].join('')); }); bdd.it('should mark one locations', function () { var code = ' * Copyright (C) 2008-2014 SonarSource', locations = [{ from: 15, to: 20 }], result = helper(code, locations, 'x'); assert.equal(result, ' * Copyright (C) 2008-2014 SonarSource'); }); bdd.it('should mark two locations', function () { var code = ' * Copyright (C) 2008-2014 SonarSource', locations = [ { from: 24, to: 29 }, { from: 15, to: 20 } ], result = helper(code, locations, 'x'); assert.equal(result, ' * Copyright (C) 2008-2014 SonarSource'); // * Copyright (C) 2008-204 SonarSource }); bdd.it('should parse line with < and >', function () { var code = '#include <stdio.h>', result = helper(code, []); assert.equal(result, '#include <stdio.h>'); }); }); });