@@ -199,6 +199,95 @@ AtRules('finds @font-face', () => {
199199 assert . equal ( actual , expected )
200200} )
201201
202+ AtRules ( 'finds @font-face' , ( ) => {
203+ const fixture = `
204+ @font-face {
205+ font-family: Arial;
206+ src: url("https://url-to-arial.woff");
207+ }
208+
209+ @font-face {
210+ font-display: swap;
211+ font-family: Test;
212+ font-stretch: condensed;
213+ font-style: italic;
214+ font-weight: 700;
215+ font-variant: no-common-ligatures proportional-nums;
216+ font-feature-settings: "liga" 0;
217+ font-variation-settings: "xhgt" 0.7;
218+ src: local("Input Mono");
219+ unicode-range: U+0025-00FF;
220+ }
221+
222+ @font-face {
223+ font-family: 'Input Mono';
224+ src: local('Input Mono') url("https://url-to-input-mono.woff");
225+ }
226+
227+ @font-face {
228+ font-family: MyHelvetica;
229+ src: local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"), url(MgOpenModernaBold.ttf);
230+ font-weight: bold;
231+ }
232+
233+ /* Duplicate @font-face in Media Query */
234+ @media (min-width: 1000px) {
235+ @font-face {
236+ font-family: 'Input Mono';
237+ src: local('Input Mono') url("https://url-to-input-mono.woff");
238+ }
239+ }`
240+ const actual = analyze ( fixture , {
241+ useUnstableLocations : true
242+ } ) . atrules . fontface . __unstable_uniqueWithLocations
243+ const expected = {
244+ total : 5 ,
245+ totalUnique : 5 ,
246+ unique : {
247+ 5 : 1 ,
248+ 100 : 1 ,
249+ 463 : 1 ,
250+ 590 : 1 ,
251+ 850 : 1 ,
252+ } ,
253+ __unstable__uniqueWithLocations : {
254+ 5 : [ {
255+ line : 2 ,
256+ column : 5 ,
257+ offset : 5 ,
258+ length : 89 ,
259+ } ] ,
260+ 100 : [ {
261+ line : 7 ,
262+ column : 5 ,
263+ offset : 100 ,
264+ length : 357 ,
265+ } ] ,
266+ 463 : [ {
267+ line : 20 ,
268+ column : 5 ,
269+ offset : 463 ,
270+ length : 121 ,
271+ } ] ,
272+ 590 : [ {
273+ line : 25 ,
274+ column : 5 ,
275+ offset : 590 ,
276+ length : 173 ,
277+ } ] ,
278+ 850 : [ {
279+ line : 33 ,
280+ column : 7 ,
281+ offset : 850 ,
282+ length : 127 ,
283+ } ] ,
284+ } ,
285+ uniquenessRatio : 1
286+ }
287+
288+ assert . equal ( actual , expected )
289+ } )
290+
202291AtRules ( 'handles @font-face encoding issues (GH-307)' , ( ) => {
203292 // Actual CSS once found in a <style> tag on vistaprint.nl
204293 // CSSTree parses it without errors, but analyzer failed on it;
0 commit comments