mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* webpack poc, this is not going to work for plugins, dam * tech: webpack and systemjs for plugins starting to work * tech: webpack and systemjs combo starting to work * tech: webpack + karma tests progress * tech: webpack + karma progress * tech: working on tests * tech: webpack * tech: webpack + karma, all tests pass * tech: webpack + karma, all tests pass * tech: webpack all tests pass * webpack: getting closer * tech: webpack progress * webpack: further build refinements * webpack: ng annotate fixes * webpack: optimized build fix * tech: minor fix for elasticsearch * tech: webpack + ace editor * tech: restored lodash move mixin compatability * tech: added enzyme react test and upgraded to react v16 * tech: package version fix * tech: added testdata to built in bundle * webpack: sass progress * tech: prod & dev build is working for the sass * tech: clean up unused grunt stuff and moved to scripts folder * tech: added vendor and manifest chunks, updated readme and docs * tech: webpack finishing touches
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import {describe, beforeEach, it, expect, angularMocks} from 'test/lib/common';
|
|
import 'app/features/panellinks/linkSrv';
|
|
import _ from 'lodash';
|
|
|
|
describe('linkSrv', function() {
|
|
var _linkSrv;
|
|
|
|
beforeEach(angularMocks.module('grafana.core'));
|
|
beforeEach(angularMocks.module('grafana.services'));
|
|
|
|
beforeEach(angularMocks.inject(function(linkSrv) {
|
|
_linkSrv = linkSrv;
|
|
}));
|
|
|
|
describe('when appending query strings', function() {
|
|
|
|
it('add ? to URL if not present', function() {
|
|
var url = _linkSrv.appendToQueryString('http://example.com', 'foo=bar');
|
|
expect(url).to.be('http://example.com?foo=bar');
|
|
});
|
|
|
|
it('do not add & to URL if ? is present but query string is empty', function() {
|
|
var url = _linkSrv.appendToQueryString('http://example.com?', 'foo=bar');
|
|
expect(url).to.be('http://example.com?foo=bar');
|
|
});
|
|
|
|
it('add & to URL if query string is present', function() {
|
|
var url = _linkSrv.appendToQueryString('http://example.com?foo=bar', 'hello=world');
|
|
expect(url).to.be('http://example.com?foo=bar&hello=world');
|
|
});
|
|
|
|
it('do not change the URL if there is nothing to append', function() {
|
|
_.each(['', undefined, null], function(toAppend) {
|
|
var url1 = _linkSrv.appendToQueryString('http://example.com', toAppend);
|
|
expect(url1).to.be('http://example.com');
|
|
|
|
var url2 = _linkSrv.appendToQueryString('http://example.com?', toAppend);
|
|
expect(url2).to.be('http://example.com?');
|
|
|
|
var url3 = _linkSrv.appendToQueryString('http://example.com?foo=bar', toAppend);
|
|
expect(url3).to.be('http://example.com?foo=bar');
|
|
});
|
|
});
|
|
|
|
});
|
|
});
|