webfontloader 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/Gemfile +2 -8
- data/README.md +31 -32
- data/Rakefile +2 -33
- data/docs/EVENTS.md +10 -1
- data/docs/MODULES.md +4 -3
- data/lib/webfontloader.rb +1 -1
- data/spec/ascender/ascenderscript_spec.js +43 -0
- data/spec/core/cssclassname_spec.js +42 -0
- data/spec/core/cssfontfamilyname_spec.js +38 -0
- data/spec/core/domhelper_spec.js +158 -0
- data/spec/core/eventdispatcher_spec.js +209 -0
- data/spec/core/font_spec.js +218 -0
- data/spec/core/fontmoduleloader_spec.js +55 -0
- data/spec/core/fontruler_spec.js +33 -0
- data/spec/core/fontvariationdescription_spec.js +67 -0
- data/spec/core/fontwatcher_spec.js +204 -0
- data/spec/core/fontwatchrunner_spec.js +398 -0
- data/spec/core/size_spec.js +17 -0
- data/spec/core/useragentparser_spec.js +921 -0
- data/spec/custom/customcss_spec.js +36 -0
- data/spec/fontdeck/fontdeckscript_spec.js +111 -0
- data/spec/fonts/LICENSE.txt +93 -0
- data/spec/fonts/nullfont.css +1 -0
- data/spec/fonts/nullfont1.css +1 -0
- data/spec/fonts/nullfont2.css +1 -0
- data/spec/fonts/nullfont3.css +1 -0
- data/spec/fonts/sourcesans.eot +0 -0
- data/spec/fonts/sourcesans.otf +0 -0
- data/spec/fonts/sourcesans.svg +2523 -0
- data/spec/fonts/sourcesans.ttf +0 -0
- data/spec/fonts/sourcesans.woff +0 -0
- data/spec/fonts/sourcesansa.css +1 -0
- data/spec/fonts/sourcesansb.css +1 -0
- data/spec/google/fontapiparser_spec.js +348 -0
- data/spec/google/fontapiurlbuilder_spec.js +40 -0
- data/spec/google/googlefontapi_spec.js +123 -0
- data/spec/google/lastresortwebkitfontwatchrunner_spec.js +145 -0
- data/spec/index.html +95 -0
- data/spec/monotype/monotypescript_spec.js +49 -0
- data/spec/typekit/typekitscript_spec.js +93 -0
- data/src/core/domhelper.js +6 -3
- data/src/core/fontruler.js +1 -1
- data/src/core/fontwatcher.js +5 -0
- data/src/core/fontwatchrunner.js +7 -4
- data/src/monotype/monotype_script.js +4 -3
- data/tools/jasmine-phantomjs/jasmine-phantomjs.js +26 -0
- data/tools/jasmine-phantomjs/terminal-reporter.js +177 -0
- data/tools/jasmine/MIT.LICENSE +20 -0
- data/tools/jasmine/jasmine-html.js +681 -0
- data/tools/jasmine/jasmine.css +82 -0
- data/tools/jasmine/jasmine.js +2600 -0
- data/webfontloader.gemspec +46 -25
- metadata +77 -42
- data/src-test/ascender/ascender_script_test.js +0 -51
- data/src-test/core/cssclassnametest.js +0 -42
- data/src-test/core/cssfontfamilynametest.js +0 -54
- data/src-test/core/domhelpertest.js +0 -151
- data/src-test/core/eventdispatchertest.js +0 -275
- data/src-test/core/fontmoduleloadertest.js +0 -30
- data/src-test/core/fonttest.js +0 -121
- data/src-test/core/fontvariationdescriptiontest.js +0 -76
- data/src-test/core/fontwatchertest.js +0 -287
- data/src-test/core/fontwatchrunnertest.js +0 -454
- data/src-test/core/useragenttest.js +0 -755
- data/src-test/custom/customcsstest.js +0 -35
- data/src-test/fontdeck/fontdeck_script_test.js +0 -116
- data/src-test/google/fontapiparsertest.js +0 -252
- data/src-test/google/fontapiurlbuildertest.js +0 -71
- data/src-test/google/googlefontapitest.js +0 -185
- data/src-test/google/lastresortwebkitfontwatchrunnertest.js +0 -204
- data/src-test/monotype/monotype_script_test.js +0 -304
- data/src-test/typekit/typekit_script_test.js +0 -195
- data/tools/jstestdriver/JsTestDriver-1.2.1.jar +0 -0
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
@font-face{font-family:SourceSansA;src:url(sourcesans.eot?#iefix) format('embedded-opentype'),url(sourcesans.woff) format('woff'),url(sourcesans.otf) format('opentype'),url(sourcesans.ttf) format('truetype'),url(sourcesans.svg#source_sans_proregular) format('svg');}
|
@@ -0,0 +1 @@
|
|
1
|
+
@font-face{font-family:SourceSansB;src:url(sourcesans.eot?#iefix) format('embedded-opentype'),url(sourcesans.woff) format('woff'),url(sourcesans.otf) format('opentype'),url(sourcesans.ttf) format('truetype'),url(sourcesans.svg#source_sans_proregular) format('svg');}
|
@@ -0,0 +1,348 @@
|
|
1
|
+
describe('FontApiParser', function () {
|
2
|
+
var FontApiParser = webfont.FontApiParser;
|
3
|
+
|
4
|
+
describe('parsed values are coherent', function () {
|
5
|
+
var parser = null;
|
6
|
+
|
7
|
+
beforeEach(function () {
|
8
|
+
parser = new FontApiParser(['Tangerine', 'Droid Serif:bi', 'Yanone Kaffeesatz:200,300,400,700', 'Cantarell:italic,b', 'Exo:100italic', 'Lobster:200n']);
|
9
|
+
parser.parse();
|
10
|
+
});
|
11
|
+
|
12
|
+
it('should parse families correctly', function () {
|
13
|
+
var fontFamilies = parser.getFontFamilies();
|
14
|
+
|
15
|
+
expect(fontFamilies.length).toEqual(6);
|
16
|
+
expect(fontFamilies).toEqual([
|
17
|
+
'Tangerine',
|
18
|
+
'Droid Serif',
|
19
|
+
'Yanone Kaffeesatz',
|
20
|
+
'Cantarell',
|
21
|
+
'Exo',
|
22
|
+
'Lobster'
|
23
|
+
]);
|
24
|
+
});
|
25
|
+
|
26
|
+
it('should parse variations correctly', function () {
|
27
|
+
var variations = parser.getVariations();
|
28
|
+
|
29
|
+
var tangerine = variations['Tangerine'];
|
30
|
+
expect(tangerine).not.toBeNull();
|
31
|
+
expect(tangerine.length).toEqual(1);
|
32
|
+
expect(tangerine[0]).toEqual('n4');
|
33
|
+
|
34
|
+
var droidSerif = variations['Droid Serif'];
|
35
|
+
expect(droidSerif).not.toBeNull();
|
36
|
+
expect(droidSerif.length).toEqual(1);
|
37
|
+
expect(droidSerif[0]).toEqual('i7');
|
38
|
+
|
39
|
+
var yanoneKaffeesatz = variations['Yanone Kaffeesatz'];
|
40
|
+
expect(yanoneKaffeesatz).not.toBeNull();
|
41
|
+
expect(yanoneKaffeesatz.length).toEqual(4);
|
42
|
+
expect(yanoneKaffeesatz[0]).toEqual('n2');
|
43
|
+
expect(yanoneKaffeesatz[1]).toEqual('n3');
|
44
|
+
expect(yanoneKaffeesatz[2]).toEqual('n4');
|
45
|
+
expect(yanoneKaffeesatz[3]).toEqual('n7');
|
46
|
+
|
47
|
+
var cantarell = variations['Cantarell'];
|
48
|
+
expect(cantarell).not.toBeNull();
|
49
|
+
expect(cantarell.length).toEqual(2);
|
50
|
+
expect(cantarell[0]).toEqual('i4');
|
51
|
+
expect(cantarell[1]).toEqual('n7');
|
52
|
+
|
53
|
+
var exo = variations['Exo'];
|
54
|
+
expect(exo).not.toBeNull();
|
55
|
+
expect(exo.length).toEqual(1);
|
56
|
+
expect(exo[0]).toEqual('i1');
|
57
|
+
|
58
|
+
var lobster = variations['Lobster'];
|
59
|
+
expect(lobster).not.toBeNull();
|
60
|
+
expect(lobster.length).toEqual(1);
|
61
|
+
expect(lobster[0]).toEqual('n2');
|
62
|
+
});
|
63
|
+
});
|
64
|
+
|
65
|
+
describe('mix of numeric weight and style', function () {
|
66
|
+
var parser = null;
|
67
|
+
|
68
|
+
beforeEach(function () {
|
69
|
+
parser = new FontApiParser(['Nobile:700i,b,200i,r,i700']);
|
70
|
+
parser.parse();
|
71
|
+
});
|
72
|
+
|
73
|
+
it('should parse families correctly', function () {
|
74
|
+
var families = parser.getFontFamilies();
|
75
|
+
|
76
|
+
expect(families.length).toEqual(1);
|
77
|
+
expect(families[0]).toEqual('Nobile');
|
78
|
+
});
|
79
|
+
|
80
|
+
it('should parse variations correctly', function () {
|
81
|
+
var variations = parser.getVariations(),
|
82
|
+
nobile = variations['Nobile'];
|
83
|
+
|
84
|
+
expect(nobile).not.toBeNull();
|
85
|
+
expect(nobile.length).toEqual(4);
|
86
|
+
expect(nobile[0]).toEqual('i7');
|
87
|
+
expect(nobile[1]).toEqual('n7');
|
88
|
+
expect(nobile[2]).toEqual('i2');
|
89
|
+
expect(nobile[3]).toEqual('n4');
|
90
|
+
});
|
91
|
+
});
|
92
|
+
|
93
|
+
describe('typo bild instead of bold', function () {
|
94
|
+
var parser = null;
|
95
|
+
|
96
|
+
beforeEach(function () {
|
97
|
+
parser = new FontApiParser(['Nobile:bild']);
|
98
|
+
parser.parse();
|
99
|
+
});
|
100
|
+
|
101
|
+
it('should parse families correctly', function () {
|
102
|
+
var families = parser.getFontFamilies();
|
103
|
+
|
104
|
+
expect(families.length).toEqual(1);
|
105
|
+
expect(families[0]).toEqual('Nobile');
|
106
|
+
});
|
107
|
+
|
108
|
+
it('should parse variations correctly', function () {
|
109
|
+
var variations = parser.getVariations(),
|
110
|
+
nobile = variations['Nobile'];
|
111
|
+
|
112
|
+
expect(nobile).not.toBeNull();
|
113
|
+
expect(nobile.length).toEqual(1);
|
114
|
+
expect(nobile[0]).toEqual('n4');
|
115
|
+
});
|
116
|
+
});
|
117
|
+
|
118
|
+
describe('nonsense', function () {
|
119
|
+
var parser = null;
|
120
|
+
|
121
|
+
beforeEach(function () {
|
122
|
+
parser = new FontApiParser(['Nobile:dwe,^%^%fewf,$9940@#!@#$%^&*()_+}POIBJ{}{']);
|
123
|
+
parser.parse();
|
124
|
+
});
|
125
|
+
|
126
|
+
it('should parse families correctly', function () {
|
127
|
+
var families = parser.getFontFamilies();
|
128
|
+
|
129
|
+
expect(families.length).toEqual(1);
|
130
|
+
expect(families[0]).toEqual('Nobile');
|
131
|
+
});
|
132
|
+
|
133
|
+
it('should parse variations correctly', function () {
|
134
|
+
var variations = parser.getVariations(),
|
135
|
+
nobile = variations['Nobile'];
|
136
|
+
|
137
|
+
expect(nobile).not.toBeNull();
|
138
|
+
expect(nobile.length).toEqual(1);
|
139
|
+
expect(nobile[0]).toEqual('n4');
|
140
|
+
});
|
141
|
+
});
|
142
|
+
|
143
|
+
describe('no weight and one subset defined', function () {
|
144
|
+
var parser = null;
|
145
|
+
|
146
|
+
beforeEach(function () {
|
147
|
+
parser = new FontApiParser(['Cantarell::greek']);
|
148
|
+
parser.parse();
|
149
|
+
});
|
150
|
+
|
151
|
+
it('should parse families correctly', function () {
|
152
|
+
var families = parser.getFontFamilies();
|
153
|
+
|
154
|
+
expect(families.length).toEqual(1);
|
155
|
+
expect(families[0]).toEqual('Cantarell');
|
156
|
+
});
|
157
|
+
|
158
|
+
it('should parse variations correctly', function () {
|
159
|
+
var variations = parser.getVariations(),
|
160
|
+
cantarell = variations['Cantarell'];
|
161
|
+
|
162
|
+
expect(cantarell).not.toBeNull();
|
163
|
+
expect(cantarell.length).toEqual(1);
|
164
|
+
expect(cantarell[0]).toEqual('n4');
|
165
|
+
});
|
166
|
+
|
167
|
+
it('should parse pick test strings correctly', function () {
|
168
|
+
var testStrings = parser.getFontTestStrings(),
|
169
|
+
cantarell = testStrings['Cantarell'];
|
170
|
+
|
171
|
+
expect(cantarell).not.toBeNull();
|
172
|
+
expect(cantarell).toEqual(FontApiParser.INT_FONTS['greek']);
|
173
|
+
});
|
174
|
+
});
|
175
|
+
|
176
|
+
describe('no weight and multiple subsets defined', function () {
|
177
|
+
var parser = null;
|
178
|
+
|
179
|
+
beforeEach(function () {
|
180
|
+
parser = new FontApiParser(['Cantarell::cyrillic,greek,latin']);
|
181
|
+
parser.parse();
|
182
|
+
});
|
183
|
+
|
184
|
+
it('should parse families correctly', function () {
|
185
|
+
var families = parser.getFontFamilies();
|
186
|
+
|
187
|
+
expect(families.length).toEqual(1);
|
188
|
+
expect(families[0]).toEqual('Cantarell');
|
189
|
+
});
|
190
|
+
|
191
|
+
it('should parse variations correctly', function () {
|
192
|
+
var variations = parser.getVariations(),
|
193
|
+
cantarell = variations['Cantarell'];
|
194
|
+
|
195
|
+
expect(cantarell).not.toBeNull();
|
196
|
+
expect(cantarell.length).toEqual(1);
|
197
|
+
expect(cantarell[0]).toEqual('n4');
|
198
|
+
});
|
199
|
+
|
200
|
+
it('should parse pick test strings correctly', function () {
|
201
|
+
var testStrings = parser.getFontTestStrings(),
|
202
|
+
cantarell = testStrings['Cantarell'];
|
203
|
+
|
204
|
+
expect(cantarell).not.toBeNull();
|
205
|
+
expect(cantarell).toEqual(FontApiParser.INT_FONTS['cyrillic']);
|
206
|
+
});
|
207
|
+
});
|
208
|
+
|
209
|
+
describe('weight and multiple subsets defined', function () {
|
210
|
+
var parser = null;
|
211
|
+
|
212
|
+
beforeEach(function () {
|
213
|
+
parser = new FontApiParser(['Cantarell:regular,bold:cyrillic,greek,latin']);
|
214
|
+
parser.parse();
|
215
|
+
});
|
216
|
+
|
217
|
+
it('should parse families correctly', function () {
|
218
|
+
var families = parser.getFontFamilies();
|
219
|
+
|
220
|
+
expect(families.length).toEqual(1);
|
221
|
+
expect(families[0]).toEqual('Cantarell');
|
222
|
+
});
|
223
|
+
|
224
|
+
it('should parse variations correctly', function () {
|
225
|
+
var variations = parser.getVariations(),
|
226
|
+
cantarell = variations['Cantarell'];
|
227
|
+
|
228
|
+
expect(cantarell).not.toBeNull();
|
229
|
+
expect(cantarell.length).toEqual(2);
|
230
|
+
expect(cantarell[0]).toEqual('n4');
|
231
|
+
expect(cantarell[1]).toEqual('n7');
|
232
|
+
});
|
233
|
+
|
234
|
+
it('should parse pick test strings correctly', function () {
|
235
|
+
var testStrings = parser.getFontTestStrings(),
|
236
|
+
cantarell = testStrings['Cantarell'];
|
237
|
+
|
238
|
+
expect(cantarell).not.toBeNull();
|
239
|
+
expect(cantarell).toEqual(FontApiParser.INT_FONTS['cyrillic']);
|
240
|
+
});
|
241
|
+
});
|
242
|
+
|
243
|
+
describe('Hanuman is backward compatible', function () {
|
244
|
+
var parser = null;
|
245
|
+
|
246
|
+
beforeEach(function () {
|
247
|
+
parser = new FontApiParser(['Hanuman']);
|
248
|
+
parser.parse();
|
249
|
+
});
|
250
|
+
|
251
|
+
it('should parse families correctly', function () {
|
252
|
+
var families = parser.getFontFamilies();
|
253
|
+
|
254
|
+
expect(families.length).toEqual(1);
|
255
|
+
expect(families[0]).toEqual('Hanuman');
|
256
|
+
});
|
257
|
+
|
258
|
+
it('should parse variations correctly', function () {
|
259
|
+
var variations = parser.getVariations(),
|
260
|
+
hanuman = variations['Hanuman'];
|
261
|
+
|
262
|
+
expect(hanuman).not.toBeNull();
|
263
|
+
expect(hanuman.length).toEqual(1);
|
264
|
+
expect(hanuman[0]).toEqual('n4');
|
265
|
+
});
|
266
|
+
|
267
|
+
it('should parse pick test strings correctly', function () {
|
268
|
+
var testStrings = parser.getFontTestStrings(),
|
269
|
+
hanuman = testStrings['Hanuman'];
|
270
|
+
|
271
|
+
expect(hanuman).not.toBeNull();
|
272
|
+
expect(hanuman).toEqual(FontApiParser.INT_FONTS['Hanuman']);
|
273
|
+
});
|
274
|
+
});
|
275
|
+
|
276
|
+
describe('Hanuman is forward compatible', function () {
|
277
|
+
var parser = null;
|
278
|
+
|
279
|
+
beforeEach(function () {
|
280
|
+
parser = new FontApiParser(['Hanuman::khmer']);
|
281
|
+
parser.parse();
|
282
|
+
});
|
283
|
+
|
284
|
+
it('should parse families correctly', function () {
|
285
|
+
var families = parser.getFontFamilies();
|
286
|
+
|
287
|
+
expect(families.length).toEqual(1);
|
288
|
+
expect(families[0]).toEqual('Hanuman');
|
289
|
+
});
|
290
|
+
|
291
|
+
it('should parse variations correctly', function () {
|
292
|
+
var variations = parser.getVariations(),
|
293
|
+
hanuman = variations['Hanuman'];
|
294
|
+
|
295
|
+
expect(hanuman).not.toBeNull();
|
296
|
+
expect(hanuman.length).toEqual(1);
|
297
|
+
expect(hanuman[0]).toEqual('n4');
|
298
|
+
});
|
299
|
+
|
300
|
+
it('should parse pick test strings correctly', function () {
|
301
|
+
var testStrings = parser.getFontTestStrings(),
|
302
|
+
hanuman = testStrings['Hanuman'];
|
303
|
+
|
304
|
+
expect(hanuman).not.toBeNull();
|
305
|
+
expect(hanuman).toEqual(FontApiParser.INT_FONTS['khmer']);
|
306
|
+
});
|
307
|
+
});
|
308
|
+
|
309
|
+
describe('plus replaced with space', function () {
|
310
|
+
var parser = null;
|
311
|
+
|
312
|
+
beforeEach(function () {
|
313
|
+
parser = new FontApiParser(['Erica+One', 'Droid+Serif::latin', 'Yanone+Kaffeesatz:400,700:latin']);
|
314
|
+
parser.parse();
|
315
|
+
});
|
316
|
+
|
317
|
+
it('should parse families correctly', function () {
|
318
|
+
var fontFamilies = parser.getFontFamilies();
|
319
|
+
|
320
|
+
expect(fontFamilies.length).toEqual(3);
|
321
|
+
expect(fontFamilies).toEqual([
|
322
|
+
'Erica One',
|
323
|
+
'Droid Serif',
|
324
|
+
'Yanone Kaffeesatz'
|
325
|
+
]);
|
326
|
+
});
|
327
|
+
|
328
|
+
it('should parse variations correctly', function () {
|
329
|
+
var variations = parser.getVariations();
|
330
|
+
|
331
|
+
var ericaOne = variations['Erica One'];
|
332
|
+
expect(ericaOne).not.toBeNull();
|
333
|
+
expect(ericaOne.length).toEqual(1);
|
334
|
+
expect(ericaOne[0]).toEqual('n4');
|
335
|
+
|
336
|
+
var droidSerif = variations['Droid Serif'];
|
337
|
+
expect(droidSerif).not.toBeNull();
|
338
|
+
expect(droidSerif.length).toEqual(1);
|
339
|
+
expect(droidSerif[0]).toEqual('n4');
|
340
|
+
|
341
|
+
var yanoneKaffeesatz = variations['Yanone Kaffeesatz'];
|
342
|
+
expect(yanoneKaffeesatz).not.toBeNull();
|
343
|
+
expect(yanoneKaffeesatz.length).toEqual(2);
|
344
|
+
expect(yanoneKaffeesatz[0]).toEqual('n4');
|
345
|
+
expect(yanoneKaffeesatz[1]).toEqual('n7');
|
346
|
+
});
|
347
|
+
});
|
348
|
+
});
|
@@ -0,0 +1,40 @@
|
|
1
|
+
describe('FontApiUrlBuilder', function () {
|
2
|
+
var FontApiUrlBuilder = webfont.FontApiUrlBuilder;
|
3
|
+
|
4
|
+
it('should throw an exception if there are no font families', function () {
|
5
|
+
var builder = new FontApiUrlBuilder('http://moo', 'http:');
|
6
|
+
expect(builder.build).toThrow();
|
7
|
+
});
|
8
|
+
|
9
|
+
it('should build a proper url', function () {
|
10
|
+
var builder = new FontApiUrlBuilder('http://moo', 'http:');
|
11
|
+
builder.setFontFamilies(['Font1', 'Font2']);
|
12
|
+
expect(builder.build()).toEqual('http://moo?family=Font1%7CFont2');
|
13
|
+
});
|
14
|
+
|
15
|
+
it('should build a proper url', function () {
|
16
|
+
var builder = new FontApiUrlBuilder(undefined, 'http:');
|
17
|
+
builder.setFontFamilies(['Font1', 'Font2']);
|
18
|
+
expect(builder.build()).toEqual('http:' +
|
19
|
+
FontApiUrlBuilder.DEFAULT_API_URL +
|
20
|
+
'?family=Font1%7CFont2');
|
21
|
+
});
|
22
|
+
|
23
|
+
it('should build a proper url', function () {
|
24
|
+
var builder = new FontApiUrlBuilder(undefined, 'http:');
|
25
|
+
builder.setFontFamilies(['Font1:bold:greek,cyrillic', 'Font2:italic', 'Font3']);
|
26
|
+
expect(builder.build()).toEqual('http:' +
|
27
|
+
FontApiUrlBuilder.DEFAULT_API_URL +
|
28
|
+
'?family=Font1:bold%7CFont2:italic%7CFont3' +
|
29
|
+
'&subset=greek,cyrillic');
|
30
|
+
});
|
31
|
+
|
32
|
+
it('should build a proper url', function () {
|
33
|
+
var builder = new FontApiUrlBuilder(undefined, 'http:');
|
34
|
+
builder.setFontFamilies(['Font1:bold,italic:greek,cyrillic', 'Font2:italic', 'Font3::latin']);
|
35
|
+
expect(builder.build()).toEqual('http:' +
|
36
|
+
FontApiUrlBuilder.DEFAULT_API_URL +
|
37
|
+
'?family=Font1:bold,italic%7CFont2:italic%7CFont3' +
|
38
|
+
'&subset=greek,cyrillic,latin');
|
39
|
+
});
|
40
|
+
});
|
@@ -0,0 +1,123 @@
|
|
1
|
+
describe('GoogleFontApi', function () {
|
2
|
+
var GoogleFontApi = webfont.GoogleFontApi,
|
3
|
+
UserAgent = webfont.UserAgent,
|
4
|
+
userAgent = null,
|
5
|
+
link = '',
|
6
|
+
insert = '',
|
7
|
+
fakeDomHelper = {
|
8
|
+
insertInto: function (tag, e) {
|
9
|
+
insert = tag;
|
10
|
+
},
|
11
|
+
createCssLink: function (cssLink) {
|
12
|
+
link = cssLink;
|
13
|
+
},
|
14
|
+
getProtocol: function () {
|
15
|
+
return 'http:';
|
16
|
+
}
|
17
|
+
};
|
18
|
+
|
19
|
+
|
20
|
+
beforeEach(function () {
|
21
|
+
insert = '';
|
22
|
+
link = '';
|
23
|
+
userAgent = new UserAgent('Test', '1.0', true);
|
24
|
+
});
|
25
|
+
|
26
|
+
describe('call onReady with font family loading', function () {
|
27
|
+
var googleFontApi = null,
|
28
|
+
families = null,
|
29
|
+
descriptions = null;
|
30
|
+
|
31
|
+
beforeEach(function () {
|
32
|
+
googleFontApi = new GoogleFontApi(userAgent, fakeDomHelper, { families: ['Font1', 'Font2'] });
|
33
|
+
googleFontApi.load(function (fontFamilies, fontDescriptions) {
|
34
|
+
families = fontFamilies;
|
35
|
+
descriptions = fontDescriptions;
|
36
|
+
});
|
37
|
+
});
|
38
|
+
|
39
|
+
it('has inserted the link element correctly', function () {
|
40
|
+
expect(insert).toEqual('head');
|
41
|
+
expect(link).toEqual('http://fonts.googleapis.com/css?family=Font1%7CFont2');
|
42
|
+
});
|
43
|
+
|
44
|
+
it('has the correct families', function () {
|
45
|
+
expect(families).not.toBeNull();
|
46
|
+
expect(families.length).toEqual(2);
|
47
|
+
expect(families[0]).toEqual('Font1');
|
48
|
+
expect(families[1]).toEqual('Font2');
|
49
|
+
});
|
50
|
+
|
51
|
+
it('has the correct font descriptions', function () {
|
52
|
+
var font1 = descriptions['Font1'];
|
53
|
+
expect(font1).not.toBeNull();
|
54
|
+
expect(font1.length).toEqual(1);
|
55
|
+
expect(font1[0]).toEqual('n4');
|
56
|
+
|
57
|
+
var font2 = descriptions['Font2'];
|
58
|
+
expect(font2).not.toBeNull();
|
59
|
+
expect(font2.length).toEqual(1);
|
60
|
+
expect(font1[0]).toEqual('n4');
|
61
|
+
});
|
62
|
+
});
|
63
|
+
|
64
|
+
describe('call onReady with font family loading and custom API url', function () {
|
65
|
+
var googleFontApi = null,
|
66
|
+
families = null,
|
67
|
+
descriptions = null;
|
68
|
+
|
69
|
+
beforeEach(function () {
|
70
|
+
googleFontApi = new GoogleFontApi(userAgent, fakeDomHelper, {
|
71
|
+
api: 'http://moo',
|
72
|
+
families: ['Font1', 'Font2']
|
73
|
+
});
|
74
|
+
googleFontApi.load(function (fontFamilies, fontDescriptions) {
|
75
|
+
families = fontFamilies;
|
76
|
+
descriptions = fontDescriptions;
|
77
|
+
});
|
78
|
+
});
|
79
|
+
|
80
|
+
it('has inserted the link element correctly', function () {
|
81
|
+
expect(insert).toEqual('head');
|
82
|
+
expect(link).toEqual('http://moo?family=Font1%7CFont2');
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
describe('spaces replaced by plus', function () {
|
87
|
+
var googleFontApi = null,
|
88
|
+
families = null,
|
89
|
+
descriptions = null;
|
90
|
+
|
91
|
+
beforeEach(function () {
|
92
|
+
googleFontApi = new GoogleFontApi(userAgent, fakeDomHelper, { families: ['Font1 WithSpace', 'Font2 WithSpaceToo'] });
|
93
|
+
googleFontApi.load(function (fontFamilies, fontDescriptions) {
|
94
|
+
families = fontFamilies;
|
95
|
+
descriptions = fontDescriptions;
|
96
|
+
});
|
97
|
+
});
|
98
|
+
|
99
|
+
it('has inserted the link element correctly', function () {
|
100
|
+
expect(insert).toEqual('head');
|
101
|
+
expect(link).toEqual('http://fonts.googleapis.com/css?family=Font1+WithSpace%7CFont2+WithSpaceToo');
|
102
|
+
});
|
103
|
+
});
|
104
|
+
|
105
|
+
describe('load with variations', function () {
|
106
|
+
var googleFontApi = null,
|
107
|
+
families = null,
|
108
|
+
descriptions = null;
|
109
|
+
|
110
|
+
beforeEach(function () {
|
111
|
+
googleFontApi = new GoogleFontApi(userAgent, fakeDomHelper, { families: ['Font1 WithSpace:bi', 'Font2 WithSpaceToo:b,r'] });
|
112
|
+
googleFontApi.load(function (fontFamilies, fontDescriptions) {
|
113
|
+
families = fontFamilies;
|
114
|
+
descriptions = fontDescriptions;
|
115
|
+
});
|
116
|
+
});
|
117
|
+
|
118
|
+
it('has inserted the link element correctly', function () {
|
119
|
+
expect(insert).toEqual('head');
|
120
|
+
expect(link).toEqual('http://fonts.googleapis.com/css?family=Font1+WithSpace:bi%7CFont2+WithSpaceToo:b,r');
|
121
|
+
});
|
122
|
+
});
|
123
|
+
});
|