Skip to content

Commit fb7a40c

Browse files
committed
Add/update tests to check fallback value
1 parent e719f74 commit fb7a40c

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

test/jasmine/tests/lib_test.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,16 +2602,6 @@ describe('Test lib.js:', function () {
26022602
).toEqual('foo asdf jkl;');
26032603
});
26042604

2605-
it('replaces missing matches with fallback value', function () {
2606-
expect(
2607-
Lib.hovertemplateString({
2608-
data: [{ group: 1 }],
2609-
fallback: '',
2610-
template: 'foo %{group} %{trace}'
2611-
})
2612-
).toEqual('foo 1 ');
2613-
});
2614-
26152605
it('uses the value from the first object with the specified key', function () {
26162606
var obj1 = { a: 'first' };
26172607
var obj2 = { a: 'second', foo: { bar: 'bar' } };
@@ -2711,7 +2701,19 @@ describe('Test lib.js:', function () {
27112701
for (var i = 0; i < 15; i++) {
27122702
Lib.hovertemplateString({ fallback: '', template: '%{idontexist}' });
27132703
}
2714-
expect(Lib.warn.calls.count()).toBe(10);
2704+
// Expect 11 since the suppression warning also calls Lib.warn
2705+
expect(Lib.warn.calls.count()).toBe(11);
2706+
});
2707+
2708+
// This test must come after the warning count since it will affect the count
2709+
it('replaces missing matches with fallback value', function () {
2710+
expect(
2711+
Lib.hovertemplateString({
2712+
data: [{ group: 1 }],
2713+
fallback: 'Planet Express',
2714+
template: 'foo %{group} %{trace}'
2715+
})
2716+
).toEqual('foo 1 Planet Express');
27152717
});
27162718
});
27172719

@@ -2755,8 +2757,20 @@ describe('Test lib.js:', function () {
27552757
for (var i = 0; i < 15; i++) {
27562758
Lib.texttemplateString({ fallback: '', template: '%{idontexist}' });
27572759
}
2760+
// Expect 11 since the suppression warning also calls Lib.warn
27582761
expect(Lib.warn.calls.count()).toBe(11);
27592762
});
2763+
2764+
// This test must come after the warning count since it will affect the count
2765+
it('replaces missing matches with fallback value', function () {
2766+
expect(
2767+
Lib.texttemplateString({
2768+
data: [{ group: 1 }],
2769+
fallback: 'Zoidberg',
2770+
template: 'foo %{group} %{trace}'
2771+
})
2772+
).toEqual('foo 1 Zoidberg');
2773+
});
27602774
});
27612775

27622776
describe('relativeAttr()', function () {

0 commit comments

Comments
 (0)