diff --git a/test/02-generate.js b/test/02-generate.js
index 26adc263..89d45444 100644
--- a/test/02-generate.js
+++ b/test/02-generate.js
@@ -341,4 +341,19 @@ describe('Module - generate', function () {
height: 900
}, assertCritical(target, expected, done));
});
+
+ it('should handle ignore "@font-face"', function (done) {
+ var expected = read('expected/generate-ignorefont.css', true);
+ var target = '.ignorefont.css';
+
+ critical.generate({
+ base: 'fixtures/',
+ src: 'generate-ignorefont.html',
+ dest: target,
+ ignore: ['@font-face'],
+ minify: true,
+ width: 1300,
+ height: 900
+ }, assertCritical(target, expected, done));
+ });
});
diff --git a/test/06-streams.js b/test/06-streams.js
index 734b549a..335e6631 100644
--- a/test/06-streams.js
+++ b/test/06-streams.js
@@ -145,7 +145,7 @@ describe('Streams', function () {
.pipe(streamAssert.end(done));
});
- it('should use ignore css files not specified when using css option (inline)', function (done) {
+ it('should ignore css files not specified when using css option (inline)', function (done) {
var stream = critical.stream({
base: path.join(__dirname, 'fixtures'),
width: 1920,
@@ -165,4 +165,44 @@ describe('Streams', function () {
}))
.pipe(streamAssert.end(done));
});
+
+ it('should respect ignore option (inline)', function(done){
+ var stream = critical.stream({
+ base: path.join(__dirname, 'fixtures'),
+ css: ['fixtures/styles/font.css'],
+ inline: false,
+ ignore: [/font-face/]
+ });
+
+ var expected = read('expected/generate-ignorefont.css');
+
+ getVinyl('generate-ignorefont.html')
+ .pipe(stream)
+ .pipe(streamAssert.length(1))
+ .pipe(streamAssert.nth(0,function (d) {
+ path.extname(d.path).should.eql('.css');
+ assert.strictEqual(nn(d.contents.toString('utf8')), expected);
+ }))
+ .pipe(streamAssert.end(done));
+ });
+
+ it('should respect ignore option (inline)', function(done){
+ var stream = critical.stream({
+ base: path.join(__dirname, 'fixtures'),
+ css: ['fixtures/styles/font.css'],
+ inline: true,
+ ignore: ['@font-face']
+ });
+
+ var expected = read('expected/generate-ignorefont.html');
+
+ getVinyl('generate-ignorefont.html')
+ .pipe(stream)
+ .pipe(streamAssert.length(1))
+ .pipe(streamAssert.nth(0,function (d) {
+ path.extname(d.path).should.eql('.html');
+ assert.strictEqual(nn(d.contents.toString('utf8')), expected);
+ }))
+ .pipe(streamAssert.end(done));
+ });
});
diff --git a/test/expected/generate-ignorefont.css b/test/expected/generate-ignorefont.css
new file mode 100644
index 00000000..6f316f2a
--- /dev/null
+++ b/test/expected/generate-ignorefont.css
@@ -0,0 +1,3 @@
+body {
+ font-family: 'PT Sans', sans-serif;
+}
\ No newline at end of file
diff --git a/test/expected/generate-ignorefont.html b/test/expected/generate-ignorefont.html
new file mode 100644
index 00000000..8380edbf
--- /dev/null
+++ b/test/expected/generate-ignorefont.html
@@ -0,0 +1,22 @@
+
+
+
+
+ Font-face
+
+
+
+
+
+ should be styled by @font-face
+
+
+
diff --git a/test/fixtures/generate-ignorefont.html b/test/fixtures/generate-ignorefont.html
new file mode 100644
index 00000000..71725ecf
--- /dev/null
+++ b/test/fixtures/generate-ignorefont.html
@@ -0,0 +1,12 @@
+
+
+
+
+ Font-face
+
+
+
+ should be styled by @font-face
+
+
+
diff --git a/test/fixtures/styles/font.css b/test/fixtures/styles/font.css
new file mode 100644
index 00000000..7b681b12
--- /dev/null
+++ b/test/fixtures/styles/font.css
@@ -0,0 +1,132 @@
+/* cyrillic-ext */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: normal;
+ font-weight: 400;
+ src: local('PT Sans'), local('PTSans-Regular'), url(http://fonts.gstatic.com/s/ptsans/v8/fhNmDCnjccoUYyU4ZASaLVKPGs1ZzpMvnHX-7fPOuAc.woff2) format('woff2');
+ unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
+}
+/* cyrillic */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: normal;
+ font-weight: 400;
+ src: local('PT Sans'), local('PTSans-Regular'), url(http://fonts.gstatic.com/s/ptsans/v8/BJVWev7_auVaQ__OU8Qih1KPGs1ZzpMvnHX-7fPOuAc.woff2) format('woff2');
+ unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
+}
+/* latin-ext */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: normal;
+ font-weight: 400;
+ src: local('PT Sans'), local('PTSans-Regular'), url(http://fonts.gstatic.com/s/ptsans/v8/oysROHFTu1eTZ74Hcf8V-VKPGs1ZzpMvnHX-7fPOuAc.woff2) format('woff2');
+ unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
+}
+/* latin */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: normal;
+ font-weight: 400;
+ src: local('PT Sans'), local('PTSans-Regular'), url(http://fonts.gstatic.com/s/ptsans/v8/CWlc_g68BGYDSGdpJvpktgLUuEpTyoUstqEm5AMlJo4.woff2) format('woff2');
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
+}
+/* cyrillic-ext */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: normal;
+ font-weight: 700;
+ src: local('PT Sans Bold'), local('PTSans-Bold'), url(http://fonts.gstatic.com/s/ptsans/v8/kTYfCWJhlldPf5LnG4ZnHAsYbbCjybiHxArTLjt7FRU.woff2) format('woff2');
+ unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
+}
+/* cyrillic */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: normal;
+ font-weight: 700;
+ src: local('PT Sans Bold'), local('PTSans-Bold'), url(http://fonts.gstatic.com/s/ptsans/v8/g46X4VH_KHOWAAa-HpnGPgsYbbCjybiHxArTLjt7FRU.woff2) format('woff2');
+ unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
+}
+/* latin-ext */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: normal;
+ font-weight: 700;
+ src: local('PT Sans Bold'), local('PTSans-Bold'), url(http://fonts.gstatic.com/s/ptsans/v8/hpORcvLZtemlH8gI-1S-7gsYbbCjybiHxArTLjt7FRU.woff2) format('woff2');
+ unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
+}
+/* latin */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: normal;
+ font-weight: 700;
+ src: local('PT Sans Bold'), local('PTSans-Bold'), url(http://fonts.gstatic.com/s/ptsans/v8/0XxGQsSc1g4rdRdjJKZrNAzyDMXhdD8sAj6OAJTFsBI.woff2) format('woff2');
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
+}
+/* cyrillic-ext */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: italic;
+ font-weight: 400;
+ src: local('PT Sans Italic'), local('PTSans-Italic'), url(http://fonts.gstatic.com/s/ptsans/v8/GpWpM_6S4VQLPNAQ3iWvVYX0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
+ unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
+}
+/* cyrillic */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: italic;
+ font-weight: 400;
+ src: local('PT Sans Italic'), local('PTSans-Italic'), url(http://fonts.gstatic.com/s/ptsans/v8/7dSh6BcuqDLzS2qAASIeuoX0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
+ unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
+}
+/* latin-ext */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: italic;
+ font-weight: 400;
+ src: local('PT Sans Italic'), local('PTSans-Italic'), url(http://fonts.gstatic.com/s/ptsans/v8/DVKQJxMmC9WF_oplMzlQqYX0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
+ unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
+}
+/* latin */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: italic;
+ font-weight: 400;
+ src: local('PT Sans Italic'), local('PTSans-Italic'), url(http://fonts.gstatic.com/s/ptsans/v8/PIPMHY90P7jtyjpXuZ2cLJBw1xU1rKptJj_0jans920.woff2) format('woff2');
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
+}
+/* cyrillic-ext */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: italic;
+ font-weight: 700;
+ src: local('PT Sans Bold Italic'), local('PTSans-BoldItalic'), url(http://fonts.gstatic.com/s/ptsans/v8/lILlYDvubYemzYzN7GbLkA7aC6SjiAOpAWOKfJDfVRY.woff2) format('woff2');
+ unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
+}
+/* cyrillic */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: italic;
+ font-weight: 700;
+ src: local('PT Sans Bold Italic'), local('PTSans-BoldItalic'), url(http://fonts.gstatic.com/s/ptsans/v8/lILlYDvubYemzYzN7GbLkBdwxCXfZpKo5kWAx_74bHs.woff2) format('woff2');
+ unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
+}
+/* latin-ext */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: italic;
+ font-weight: 700;
+ src: local('PT Sans Bold Italic'), local('PTSans-BoldItalic'), url(http://fonts.gstatic.com/s/ptsans/v8/lILlYDvubYemzYzN7GbLkIjoYw3YTyktCCer_ilOlhE.woff2) format('woff2');
+ unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
+}
+/* latin */
+@font-face {
+ font-family: 'PT Sans';
+ font-style: italic;
+ font-weight: 700;
+ src: local('PT Sans Bold Italic'), local('PTSans-BoldItalic'), url(http://fonts.gstatic.com/s/ptsans/v8/lILlYDvubYemzYzN7GbLkBampu5_7CjHW5spxoeN3Vs.woff2) format('woff2');
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
+}
+
+body {
+ font-family: 'PT Sans', sans-serif;
+}
\ No newline at end of file