Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Fix failed tests.
Browse files Browse the repository at this point in the history
Add browsers for features which depends on browserslist.
  • Loading branch information
Semigradsky committed May 7, 2017
1 parent 6577f6c commit 2ca6df0
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/autoprefixer.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Safari 6
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/color-hex-alpha.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Safari 9
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/color-rgba.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IE 8
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/custom-properties.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Safari 9
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/filter.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IE 11
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/initial.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Safari 9
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/overflow-wrap.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IE 11
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Safari 8
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/pseudo-class-not.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Safari 8
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/pseudo-elements.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IE 8
1 change: 1 addition & 0 deletions src/__tests__/fixtures/features/rem.browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IE 8
2 changes: 1 addition & 1 deletion src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tape("postcss-cssnext is a postcss plugin", (t) => {
tape("cssnext regression test", (t) => {
const input = utils.readFixture("regression")
const expected = utils.readFixture("regression.expected")
const actual = postcssnext().process(input).css.trim()
const actual = postcssnext({ browsers: "IE 6" }).process(input).css.trim()

utils.write(utils.fixturePath("regression.actual"), actual)

Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/option.features.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const testFeature = function(
) {
const options = { features: { } }

const browsers = utils.readFixtureBrowsers(join("features", slug))

if (browsers) {
options.browsers = browsers
}

// disable all features
Object.keys(features).forEach(function(key) {
options.features[key] = false
Expand Down
18 changes: 14 additions & 4 deletions src/__tests__/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,22 @@ export default {
},

/**
* read a fixture
* read a fixture browsers
* @param {String} name
* @param {String} ext (optional extension, default to ".css")
* @return the fixture content
* @return the fixture browsers string
*/
readFixtureBrowsers(name) {
const filePath = this.fixturePath(name, ".browsers")
const exists = fs.existsSync(filePath)
return exists && fs.readFileSync(filePath, "utf8").split("\n")[0]
},

/**
* write a result
* @param {String} name
* @param {String} content
*/
write(name, content) {
return fs.writeFileSync(name, content)
fs.writeFileSync(name, content)
},
}

0 comments on commit 2ca6df0

Please sign in to comment.