jasmine-core 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/console/console.js +1 -1
- data/lib/jasmine-core/boot.js +3 -2
- data/lib/jasmine-core/boot/boot.js +2 -1
- data/lib/jasmine-core/example/node_example/{src → lib/jasmine_examples}/Player.js +0 -0
- data/lib/jasmine-core/example/node_example/{src → lib/jasmine_examples}/Song.js +0 -0
- data/lib/jasmine-core/example/node_example/spec/{SpecHelper.js → helpers/jasmine_examples/SpecHelper.js} +0 -0
- data/lib/jasmine-core/example/node_example/spec/{PlayerSpec.js → jasmine_examples/PlayerSpec.js} +2 -2
- data/lib/jasmine-core/jasmine-html.js +17 -5
- data/lib/jasmine-core/jasmine.css +10 -10
- data/lib/jasmine-core/jasmine.js +295 -155
- data/lib/jasmine-core/node_boot.js +1 -1
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +37 -0
- data/lib/jasmine-core/spec/core/EnvSpec.js +6 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +14 -14
- data/lib/jasmine-core/spec/core/SpecSpec.js +24 -1
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +9 -0
- data/lib/jasmine-core/spec/core/SpySpec.js +9 -1
- data/lib/jasmine-core/spec/core/SuiteSpec.js +26 -0
- data/lib/jasmine-core/spec/core/{AnySpec.js → asymmetric_equality/AnySpec.js} +6 -6
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +44 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +39 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +58 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +27 -0
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +79 -3
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +26 -2
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +112 -2
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +8 -0
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +19 -8
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +1 -1
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +32 -3
- data/lib/jasmine-core/version.rb +1 -1
- metadata +96 -93
- data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +0 -70
@@ -0,0 +1,27 @@
|
|
1
|
+
describe("StringMatching", function() {
|
2
|
+
it("matches a string against a provided regexp", function() {
|
3
|
+
var matcher = new j$.StringMatching(/foo/);
|
4
|
+
|
5
|
+
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
6
|
+
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
7
|
+
});
|
8
|
+
|
9
|
+
it("matches a string against provided string", function() {
|
10
|
+
var matcher = new j$.StringMatching('foo');
|
11
|
+
|
12
|
+
expect(matcher.asymmetricMatch('barfoobaz')).toBe(true);
|
13
|
+
expect(matcher.asymmetricMatch('barbaz')).toBe(false);
|
14
|
+
});
|
15
|
+
|
16
|
+
it("raises an Error when the expected is not a String or RegExp", function() {
|
17
|
+
expect(function() {
|
18
|
+
new j$.StringMatching({});
|
19
|
+
}).toThrowError(/not a String or a RegExp/);
|
20
|
+
});
|
21
|
+
|
22
|
+
it("jasmineToString's itself", function() {
|
23
|
+
var matching = new j$.StringMatching(/^foo/);
|
24
|
+
|
25
|
+
expect(matching.jasmineToString()).toEqual("<jasmine.stringMatching(/^foo/)>");
|
26
|
+
});
|
27
|
+
});
|
@@ -161,9 +161,24 @@ describe("Env integration", function() {
|
|
161
161
|
})]
|
162
162
|
}));
|
163
163
|
expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
164
|
-
description: 'has a message from an Error',
|
164
|
+
description: 'has a message and stack trace from an Error',
|
165
165
|
failedExpectations: [jasmine.objectContaining({
|
166
|
-
message: 'Failed: error message'
|
166
|
+
message: 'Failed: error message',
|
167
|
+
stack: {
|
168
|
+
asymmetricMatch: function(other) {
|
169
|
+
if (!other) {
|
170
|
+
// IE doesn't give us a stacktrace so just ignore it.
|
171
|
+
return true;
|
172
|
+
}
|
173
|
+
var split = other.split('\n'),
|
174
|
+
firstLine = split[0];
|
175
|
+
if (firstLine.indexOf('error message') >= 0) {
|
176
|
+
// Chrome inserts the message and a newline before the first stacktrace line.
|
177
|
+
firstLine = split[1];
|
178
|
+
}
|
179
|
+
return firstLine.indexOf('EnvSpec') >= 0;
|
180
|
+
}
|
181
|
+
}
|
167
182
|
})]
|
168
183
|
}));
|
169
184
|
done();
|
@@ -179,7 +194,7 @@ describe("Env integration", function() {
|
|
179
194
|
env.fail('messy message');
|
180
195
|
});
|
181
196
|
|
182
|
-
env.it('has a message from an Error', function() {
|
197
|
+
env.it('has a message and stack trace from an Error', function() {
|
183
198
|
env.fail(new Error('error message'));
|
184
199
|
});
|
185
200
|
});
|
@@ -1122,6 +1137,67 @@ describe("Env integration", function() {
|
|
1122
1137
|
env.execute();
|
1123
1138
|
});
|
1124
1139
|
|
1140
|
+
it('should report pending spec messages', function(done) {
|
1141
|
+
var env = new j$.Env(),
|
1142
|
+
reporter = jasmine.createSpyObj('fakeReporter', [
|
1143
|
+
'specDone',
|
1144
|
+
'jasmineDone'
|
1145
|
+
]);
|
1146
|
+
|
1147
|
+
reporter.jasmineDone.and.callFake(function() {
|
1148
|
+
var specStatus = reporter.specDone.calls.argsFor(0)[0];
|
1149
|
+
|
1150
|
+
expect(specStatus.pendingReason).toBe('with a message');
|
1151
|
+
|
1152
|
+
done();
|
1153
|
+
});
|
1154
|
+
|
1155
|
+
env.addReporter(reporter);
|
1156
|
+
|
1157
|
+
env.it('will be pending', function() {
|
1158
|
+
env.pending('with a message');
|
1159
|
+
});
|
1160
|
+
|
1161
|
+
env.execute();
|
1162
|
+
});
|
1163
|
+
|
1164
|
+
it('should report xdescribes as expected', function(done) {
|
1165
|
+
var env = new j$.Env(),
|
1166
|
+
reporter = jasmine.createSpyObj('fakeReporter', [
|
1167
|
+
"jasmineStarted",
|
1168
|
+
"jasmineDone",
|
1169
|
+
"suiteStarted",
|
1170
|
+
"suiteDone",
|
1171
|
+
"specStarted",
|
1172
|
+
"specDone"
|
1173
|
+
]);
|
1174
|
+
|
1175
|
+
reporter.jasmineDone.and.callFake(function() {
|
1176
|
+
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
1177
|
+
totalSpecsDefined: 1
|
1178
|
+
});
|
1179
|
+
|
1180
|
+
expect(reporter.specDone).not.toHaveBeenCalled();
|
1181
|
+
expect(reporter.suiteDone.calls.count()).toBe(3);
|
1182
|
+
|
1183
|
+
done();
|
1184
|
+
});
|
1185
|
+
|
1186
|
+
env.addReporter(reporter);
|
1187
|
+
|
1188
|
+
env.describe("A Suite", function() {
|
1189
|
+
env.describe("nested", function() {
|
1190
|
+
env.xdescribe("xd out", function() {
|
1191
|
+
env.it("with a spec", function() {
|
1192
|
+
env.expect(true).toBe(false);
|
1193
|
+
});
|
1194
|
+
});
|
1195
|
+
});
|
1196
|
+
});
|
1197
|
+
|
1198
|
+
env.execute();
|
1199
|
+
});
|
1200
|
+
|
1125
1201
|
it("should be possible to get full name from a spec", function() {
|
1126
1202
|
var env = new j$.Env({global: { setTimeout: setTimeout }}),
|
1127
1203
|
topLevelSpec, nestedSpec, doublyNestedSpec;
|
@@ -228,7 +228,7 @@ describe("jasmine spec running", function () {
|
|
228
228
|
env.execute();
|
229
229
|
});
|
230
230
|
|
231
|
-
it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', function() {
|
231
|
+
it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', function(done) {
|
232
232
|
var actions = [];
|
233
233
|
|
234
234
|
env.beforeAll(function() {
|
@@ -289,7 +289,7 @@ describe("jasmine spec running", function () {
|
|
289
289
|
env.execute();
|
290
290
|
});
|
291
291
|
|
292
|
-
it('should run beforeAlls and afterAlls as beforeEachs and afterEachs in the order declared when runnablesToRun is provided', function() {
|
292
|
+
it('should run beforeAlls and afterAlls as beforeEachs and afterEachs in the order declared when runnablesToRun is provided', function(done) {
|
293
293
|
var actions = [],
|
294
294
|
spec,
|
295
295
|
spec2;
|
@@ -366,6 +366,30 @@ describe("jasmine spec running", function () {
|
|
366
366
|
env.execute([spec.id, spec2.id]);
|
367
367
|
});
|
368
368
|
|
369
|
+
it('only runs *Alls once in a focused suite', function(done){
|
370
|
+
var actions = [];
|
371
|
+
|
372
|
+
env.fdescribe('Suite', function() {
|
373
|
+
env.beforeAll(function(){
|
374
|
+
actions.push('beforeAll');
|
375
|
+
});
|
376
|
+
env.it('should run beforeAll once', function() {
|
377
|
+
actions.push('spec');
|
378
|
+
});
|
379
|
+
env.afterAll(function(){
|
380
|
+
actions.push('afterAll');
|
381
|
+
});
|
382
|
+
});
|
383
|
+
|
384
|
+
var assertions = function() {
|
385
|
+
expect(actions).toEqual(['beforeAll', 'spec', 'afterAll']);
|
386
|
+
done();
|
387
|
+
};
|
388
|
+
|
389
|
+
env.addReporter({jasmineDone: assertions});
|
390
|
+
env.execute();
|
391
|
+
});
|
392
|
+
|
369
393
|
describe('focused runnables', function() {
|
370
394
|
it('runs the relevant alls and eachs for each runnable', function(done) {
|
371
395
|
var actions = [];
|
@@ -58,6 +58,16 @@ describe("matchersUtil", function() {
|
|
58
58
|
expect(j$.matchersUtil.equals([1, 2], [1, 2, 3])).toBe(false);
|
59
59
|
});
|
60
60
|
|
61
|
+
it("fails for Arrays whose contents are equivalent, but have differing properties", function() {
|
62
|
+
var one = [1,2,3],
|
63
|
+
two = [1,2,3];
|
64
|
+
|
65
|
+
one.foo = 'bar';
|
66
|
+
two.foo = 'baz';
|
67
|
+
|
68
|
+
expect(j$.matchersUtil.equals(one, two)).toBe(false);
|
69
|
+
});
|
70
|
+
|
61
71
|
it("passes for Errors that are the same type and have the same message", function() {
|
62
72
|
expect(j$.matchersUtil.equals(new Error("foo"), new Error("foo"))).toBe(true);
|
63
73
|
});
|
@@ -122,6 +132,45 @@ describe("matchersUtil", function() {
|
|
122
132
|
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
123
133
|
});
|
124
134
|
|
135
|
+
it("passes for equivalent DOM nodes", function() {
|
136
|
+
if (typeof document === 'undefined') {
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
var a = document.createElement("div");
|
140
|
+
a.setAttribute("test-attr", "attr-value")
|
141
|
+
a.appendChild(document.createTextNode('test'));
|
142
|
+
|
143
|
+
var b = document.createElement("div");
|
144
|
+
b.setAttribute("test-attr", "attr-value")
|
145
|
+
b.appendChild(document.createTextNode('test'));
|
146
|
+
|
147
|
+
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
148
|
+
});
|
149
|
+
|
150
|
+
it("fails for DOM nodes with different attributes or child nodes", function() {
|
151
|
+
if (typeof document === 'undefined') {
|
152
|
+
return;
|
153
|
+
}
|
154
|
+
var a = document.createElement("div");
|
155
|
+
a.setAttribute("test-attr", "attr-value")
|
156
|
+
a.appendChild(document.createTextNode('test'));
|
157
|
+
|
158
|
+
var b = document.createElement("div");
|
159
|
+
b.setAttribute("test-attr", "attr-value2")
|
160
|
+
b.appendChild(document.createTextNode('test'));
|
161
|
+
|
162
|
+
expect(j$.matchersUtil.equals(a,b)).toBe(false);
|
163
|
+
|
164
|
+
b.setAttribute("test-attr", "attr-value");
|
165
|
+
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
166
|
+
|
167
|
+
b.appendChild(document.createTextNode('2'));
|
168
|
+
expect(j$.matchersUtil.equals(a,b)).toBe(false);
|
169
|
+
|
170
|
+
a.appendChild(document.createTextNode('2'));
|
171
|
+
expect(j$.matchersUtil.equals(a,b)).toBe(true);
|
172
|
+
});
|
173
|
+
|
125
174
|
it("passes when Any is used", function() {
|
126
175
|
var number = 3,
|
127
176
|
anyNumber = new j$.Any(Number);
|
@@ -142,9 +191,31 @@ describe("matchersUtil", function() {
|
|
142
191
|
var obj = {
|
143
192
|
foo: 3,
|
144
193
|
bar: 7
|
145
|
-
}
|
194
|
+
},
|
195
|
+
containing = new j$.ObjectContaining({foo: 3});
|
196
|
+
|
197
|
+
expect(j$.matchersUtil.equals(obj, containing)).toBe(true);
|
198
|
+
expect(j$.matchersUtil.equals(containing, obj)).toBe(true);
|
199
|
+
});
|
200
|
+
|
201
|
+
it("passes when an asymmetric equality tester returns true", function() {
|
202
|
+
var tester = { asymmetricMatch: function(other) { return true; } };
|
146
203
|
|
147
|
-
expect(j$.matchersUtil.equals(
|
204
|
+
expect(j$.matchersUtil.equals(false, tester)).toBe(true);
|
205
|
+
expect(j$.matchersUtil.equals(tester, false)).toBe(true);
|
206
|
+
});
|
207
|
+
|
208
|
+
it("fails when an asymmetric equality tester returns false", function() {
|
209
|
+
var tester = { asymmetricMatch: function(other) { return false; } };
|
210
|
+
|
211
|
+
expect(j$.matchersUtil.equals(true, tester)).toBe(false);
|
212
|
+
expect(j$.matchersUtil.equals(tester, true)).toBe(false);
|
213
|
+
});
|
214
|
+
|
215
|
+
it("passes when ArrayContaining is used", function() {
|
216
|
+
var arr = ["foo", "bar"];
|
217
|
+
|
218
|
+
expect(j$.matchersUtil.equals(arr, new j$.ArrayContaining(["bar"]))).toBe(true);
|
148
219
|
});
|
149
220
|
|
150
221
|
it("passes when a custom equality matcher returns true", function() {
|
@@ -170,6 +241,45 @@ describe("matchersUtil", function() {
|
|
170
241
|
|
171
242
|
expect(j$.matchersUtil.equals(1, 1, [tester])).toBe(false);
|
172
243
|
});
|
244
|
+
|
245
|
+
it("passes for an asymmetric equality tester that returns true when a custom equality tester return false", function() {
|
246
|
+
var asymmetricTester = { asymmetricMatch: function(other) { return true; } },
|
247
|
+
symmetricTester = function(a, b) { return false; };
|
248
|
+
|
249
|
+
expect(j$.matchersUtil.equals(asymmetricTester, true, [symmetricTester])).toBe(true);
|
250
|
+
expect(j$.matchersUtil.equals(true, asymmetricTester, [symmetricTester])).toBe(true);
|
251
|
+
});
|
252
|
+
|
253
|
+
it("passes when an Any is compared to an Any that checks for the same type", function() {
|
254
|
+
var any1 = new j$.Any(Function),
|
255
|
+
any2 = new j$.Any(Function);
|
256
|
+
|
257
|
+
expect(j$.matchersUtil.equals(any1, any2)).toBe(true);
|
258
|
+
});
|
259
|
+
|
260
|
+
it("passes for null prototype objects with same properties", function () {
|
261
|
+
if (jasmine.getEnv().ieVersion < 9) { return; }
|
262
|
+
|
263
|
+
var objA = Object.create(null),
|
264
|
+
objB = Object.create(null);
|
265
|
+
|
266
|
+
objA.name = 'test';
|
267
|
+
objB.name = 'test';
|
268
|
+
|
269
|
+
expect(j$.matchersUtil.equals(objA, objB)).toBe(true);
|
270
|
+
});
|
271
|
+
|
272
|
+
it("fails for null prototype objects with different properties", function () {
|
273
|
+
if (jasmine.getEnv().ieVersion < 9) { return; }
|
274
|
+
|
275
|
+
var objA = Object.create(null),
|
276
|
+
objB = Object.create(null);
|
277
|
+
|
278
|
+
objA.name = 'test';
|
279
|
+
objB.test = 'name';
|
280
|
+
|
281
|
+
expect(j$.matchersUtil.equals(objA, objB)).toBe(false);
|
282
|
+
});
|
173
283
|
});
|
174
284
|
|
175
285
|
describe("contains", function() {
|
@@ -30,5 +30,13 @@ describe("toMatch", function() {
|
|
30
30
|
result = matcher.compare('bar', 'foo');
|
31
31
|
expect(result.pass).toBe(false);
|
32
32
|
});
|
33
|
+
|
34
|
+
it("throws an Error when the expected is not a String or RegExp", function() {
|
35
|
+
var matcher = j$.matchers.toMatch();
|
36
|
+
|
37
|
+
expect(function() {
|
38
|
+
matcher.compare('foo', { bar: 'baz' });
|
39
|
+
}).toThrowError('Expected is not a String or a RegExp');
|
40
|
+
});
|
33
41
|
});
|
34
42
|
|
@@ -278,7 +278,8 @@ describe("New HtmlReporter", function() {
|
|
278
278
|
env: env,
|
279
279
|
getContainer: getContainer,
|
280
280
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
281
|
-
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
281
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
282
|
+
addToExistingQueryString: function(key, value) { return "?foo=bar&" + key + "=" + value; }
|
282
283
|
});
|
283
284
|
reporter.initialize();
|
284
285
|
|
@@ -350,7 +351,7 @@ describe("New HtmlReporter", function() {
|
|
350
351
|
var suiteDetail = outerSuite.childNodes[0];
|
351
352
|
var suiteLink = suiteDetail.childNodes[0];
|
352
353
|
expect(suiteLink.innerHTML).toEqual("A Suite");
|
353
|
-
expect(suiteLink.getAttribute('href')).toEqual("?spec=A
|
354
|
+
expect(suiteLink.getAttribute('href')).toEqual("?foo=bar&spec=A Suite");
|
354
355
|
|
355
356
|
var specs = outerSuite.childNodes[1];
|
356
357
|
var spec = specs.childNodes[0];
|
@@ -359,7 +360,7 @@ describe("New HtmlReporter", function() {
|
|
359
360
|
|
360
361
|
var specLink = spec.childNodes[0];
|
361
362
|
expect(specLink.innerHTML).toEqual("with a spec");
|
362
|
-
expect(specLink.getAttribute("href")).toEqual("?spec=A
|
363
|
+
expect(specLink.getAttribute("href")).toEqual("?foo=bar&spec=A Suite with a spec");
|
363
364
|
// expect(specLink.getAttribute("title")).toEqual("A Suite with a spec");
|
364
365
|
});
|
365
366
|
|
@@ -532,14 +533,17 @@ describe("New HtmlReporter", function() {
|
|
532
533
|
reporter.initialize();
|
533
534
|
|
534
535
|
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
535
|
-
|
536
|
+
var specStatus = {
|
536
537
|
id: 123,
|
537
538
|
description: "with a spec",
|
538
539
|
fullName: "A Suite with a spec",
|
539
540
|
status: "pending",
|
540
541
|
passedExpectations: [],
|
541
|
-
failedExpectations: []
|
542
|
-
|
542
|
+
failedExpectations: [],
|
543
|
+
pendingReason: "my custom pending reason"
|
544
|
+
};
|
545
|
+
reporter.specStarted(specStatus);
|
546
|
+
reporter.specDone(specStatus);
|
543
547
|
reporter.jasmineDone({});
|
544
548
|
});
|
545
549
|
|
@@ -554,6 +558,12 @@ describe("New HtmlReporter", function() {
|
|
554
558
|
|
555
559
|
expect(specFailure.childNodes.length).toEqual(0);
|
556
560
|
});
|
561
|
+
|
562
|
+
it("displays the custom pending reason", function() {
|
563
|
+
var pendingDetails = container.querySelector(".summary .pending");
|
564
|
+
|
565
|
+
expect(pendingDetails.innerHTML).toContain("my custom pending reason");
|
566
|
+
});
|
557
567
|
});
|
558
568
|
|
559
569
|
describe("and some tests fail", function() {
|
@@ -567,7 +577,8 @@ describe("New HtmlReporter", function() {
|
|
567
577
|
env: env,
|
568
578
|
getContainer: getContainer,
|
569
579
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
570
|
-
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
580
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
581
|
+
addToExistingQueryString: function(key, value) { return "?foo=bar&" + key + "=" + value; }
|
571
582
|
});
|
572
583
|
reporter.initialize();
|
573
584
|
|
@@ -614,7 +625,7 @@ describe("New HtmlReporter", function() {
|
|
614
625
|
|
615
626
|
var specLink = specDiv.childNodes[0];
|
616
627
|
expect(specLink.getAttribute("title")).toEqual("a suite with a failing spec");
|
617
|
-
expect(specLink.getAttribute("href")).toEqual("?spec=a
|
628
|
+
expect(specLink.getAttribute("href")).toEqual("?foo=bar&spec=a suite with a failing spec");
|
618
629
|
|
619
630
|
var message = failure.childNodes[1].childNodes[0];
|
620
631
|
expect(message.getAttribute("class")).toEqual("result-message");
|
@@ -3,7 +3,7 @@ describe("j$.pp (HTML Dependent)", function () {
|
|
3
3
|
var sampleNode = document.createElement('div');
|
4
4
|
sampleNode.innerHTML = 'foo<b>bar</b>';
|
5
5
|
expect(j$.pp(sampleNode)).toEqual("HTMLNode");
|
6
|
-
expect(j$.pp({foo: sampleNode})).toEqual("{ foo: HTMLNode }");
|
6
|
+
expect(j$.pp({foo: sampleNode})).toEqual("Object({ foo: HTMLNode })");
|
7
7
|
});
|
8
8
|
|
9
9
|
it("should print Firefox's wrapped native objects correctly", function() {
|
@@ -1,7 +1,6 @@
|
|
1
1
|
describe("QueryString", function() {
|
2
2
|
|
3
|
-
describe("#
|
4
|
-
|
3
|
+
describe("#navigateWithNewParam", function() {
|
5
4
|
it("sets the query string to include the given key/value pair", function() {
|
6
5
|
var windowLocation = {
|
7
6
|
search: ""
|
@@ -10,10 +9,40 @@ describe("QueryString", function() {
|
|
10
9
|
getWindowLocation: function() { return windowLocation }
|
11
10
|
});
|
12
11
|
|
13
|
-
queryString.
|
12
|
+
queryString.navigateWithNewParam("foo", "bar baz");
|
14
13
|
|
15
14
|
expect(windowLocation.search).toMatch(/foo=bar%20baz/);
|
16
15
|
});
|
16
|
+
|
17
|
+
it("leaves existing params alone", function() {
|
18
|
+
var windowLocation = {
|
19
|
+
search: "?foo=bar"
|
20
|
+
},
|
21
|
+
queryString = new j$.QueryString({
|
22
|
+
getWindowLocation: function() { return windowLocation }
|
23
|
+
});
|
24
|
+
|
25
|
+
queryString.navigateWithNewParam("baz", "quux");
|
26
|
+
|
27
|
+
expect(windowLocation.search).toMatch(/foo=bar/);
|
28
|
+
expect(windowLocation.search).toMatch(/baz=quux/);
|
29
|
+
});
|
30
|
+
});
|
31
|
+
|
32
|
+
describe('#fullStringWithNewParam', function() {
|
33
|
+
it("gets the query string including the given key/value pair", function() {
|
34
|
+
var windowLocation = {
|
35
|
+
search: "?foo=bar"
|
36
|
+
},
|
37
|
+
queryString = new j$.QueryString({
|
38
|
+
getWindowLocation: function() { return windowLocation }
|
39
|
+
});
|
40
|
+
|
41
|
+
var result = queryString.fullStringWithNewParam("baz", "quux");
|
42
|
+
|
43
|
+
expect(result).toMatch(/foo=bar/);
|
44
|
+
expect(result).toMatch(/baz=quux/);
|
45
|
+
});
|
17
46
|
});
|
18
47
|
|
19
48
|
describe("#getParam", function() {
|