-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
"gulp-replace": "0.5.2" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.15.2", | ||
"gulp-ava": "^0.12.0", | ||
"rimraf": "^2.5.2" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/react-server-gulp-module-tagger/test/fixtures/example/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var logger = require('react-server').logging.getLogger(__LOGGER__); | ||
var fooLogger = logging.getLogger(__LOGGER__({ label: "foo" })); | ||
var barLogger = logging.getLogger(__LOGGER__({ label: "bar" })); |
3 changes: 3 additions & 0 deletions
3
packages/react-server-gulp-module-tagger/test/fixtures/example/build/actual.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
packages/react-server-gulp-module-tagger/test/fixtures/example/expected.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
packages/react-server-gulp-module-tagger/test/fixtures/example/gulpfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const gulp = require('gulp'); | ||
const tagger = require('../../..'); | ||
|
||
gulp.task('default', () => { | ||
gulp.src('actual.js') | ||
.pipe(tagger()) | ||
.pipe(gulp.dest('build')); | ||
}); |
2 changes: 2 additions & 0 deletions
2
packages/react-server-gulp-module-tagger/test/fixtures/reserved-future-tokens/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__CHANNEL__ | ||
__CACHE__ |
2 changes: 2 additions & 0 deletions
2
...ages/react-server-gulp-module-tagger/test/fixtures/reserved-future-tokens/build/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"name":"react-server-gulp-module-tagger.test.fixtures.reserved-future-tokens.actual","color":{"server":205,"client":"rgb(212,42,127)"}} | ||
{"name":"react-server-gulp-module-tagger.test.fixtures.reserved-future-tokens.actual","color":{"server":205,"client":"rgb(212,42,127)"}} |
2 changes: 2 additions & 0 deletions
2
packages/react-server-gulp-module-tagger/test/fixtures/reserved-future-tokens/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"name":"react-server-gulp-module-tagger.test.fixtures.reserved-future-tokens.actual","color":{"server":205,"client":"rgb(212,42,127)"}} | ||
{"name":"react-server-gulp-module-tagger.test.fixtures.reserved-future-tokens.actual","color":{"server":205,"client":"rgb(212,42,127)"}} |
8 changes: 8 additions & 0 deletions
8
packages/react-server-gulp-module-tagger/test/fixtures/reserved-future-tokens/gulpfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const gulp = require('gulp'); | ||
const tagger = require('../../..'); | ||
|
||
gulp.task('default', () => { | ||
gulp.src('actual.js') | ||
.pipe(tagger()) | ||
.pipe(gulp.dest('build')); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/react-server-gulp-module-tagger/test/fixtures/trim/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var logger = require('react-server').logging.getLogger(__LOGGER__); | ||
var fooLogger = logging.getLogger(__LOGGER__({ label: "foo" })); | ||
var barLogger = logging.getLogger(__LOGGER__({ label: "bar" })); |
3 changes: 3 additions & 0 deletions
3
packages/react-server-gulp-module-tagger/test/fixtures/trim/build/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var logger = require('react-server').logging.getLogger({"name":"fixtures.trim.actual","color":{"server":147,"client":"rgb(127,127,212)"}}); | ||
var fooLogger = logging.getLogger({"label":"foo","name":"fixtures.trim.actual.foo","color":{"server":147,"client":"rgb(127,127,212)"}}); | ||
var barLogger = logging.getLogger({"label":"bar","name":"fixtures.trim.actual.bar","color":{"server":147,"client":"rgb(127,127,212)"}}); |
3 changes: 3 additions & 0 deletions
3
packages/react-server-gulp-module-tagger/test/fixtures/trim/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var logger = require('react-server').logging.getLogger({"name":"fixtures.trim.actual","color":{"server":147,"client":"rgb(127,127,212)"}}); | ||
var fooLogger = logging.getLogger({"label":"foo","name":"fixtures.trim.actual.foo","color":{"server":147,"client":"rgb(127,127,212)"}}); | ||
var barLogger = logging.getLogger({"label":"bar","name":"fixtures.trim.actual.bar","color":{"server":147,"client":"rgb(127,127,212)"}}); |
8 changes: 8 additions & 0 deletions
8
packages/react-server-gulp-module-tagger/test/fixtures/trim/gulpfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const gulp = require('gulp'); | ||
const tagger = require('../../..'); | ||
|
||
gulp.task('default', () => { | ||
gulp.src('actual.js') | ||
.pipe(tagger({ trim: 'react-server-gulp-module-tagger.test.' })) | ||
.pipe(gulp.dest('build')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import test from 'ava'; | ||
import fs from 'fs'; | ||
import cp from 'child_process'; | ||
import path from 'path'; | ||
|
||
getTestCases().then((testCases) => { | ||
testCases.forEach((dir) => { | ||
test(`testing fixture in ${dir}`, async t => { | ||
await runGulp(dir); | ||
const expected = await readFile(path.join('fixtures', dir, 'expected.js')); | ||
const actual = await readFile(path.join('fixtures', dir, 'build', 'actual.js')); | ||
t.is(actual.toString(), expected.toString()); | ||
}); | ||
}); | ||
}); | ||
|
||
function getTestCases() { | ||
return new Promise((resolve, reject) => { | ||
fs.readdir('fixtures', (err, data) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data); | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
function readFile(filename) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(filename, (err, data) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function runGulp(dir) { | ||
return new Promise((resolve, reject) => { | ||
dir = path.join(__dirname, 'fixtures', dir); | ||
cp.exec('gulp', { cwd: dir }, (err, stdout, stderr) => { | ||
if (err) { | ||
console.error(stderr); | ||
reject(err); | ||
} else { | ||
resolve(stdout); | ||
} | ||
}); | ||
}); | ||
} |