Skip to content

Commit 1e6cb02

Browse files
authored
Merge pull request #2 from halfzebra/0.19-tests
0.19 tests
2 parents df02ef6 + f081b57 commit 1e6cb02

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,14 @@ module.exports = function() {
179179
.then(function(results) {
180180
var output = results[results.length - 1]; // compilation output is always last
181181

182-
if (output.kind == 'success') {
182+
if (output.kind === 'success') {
183183
alreadyCompiledFiles.push(resourcePath);
184184
callback(null, output.result);
185185
} else {
186+
if (typeof output.error === 'string') {
187+
output.error = new Error(output.error);
188+
}
189+
186190
output.error.message = 'Compiler process exited with error ' + output.error.message;
187191
callback(output.error);
188192
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"elm": "^0.19.0",
2929
"glob": "^7.1.1",
3030
"loader-utils": "^1.0.2",
31-
"node-elm-compiler": "rtfeldman/node-elm-compiler#0.19",
31+
"node-elm-compiler": "^5.0.0",
3232
"yargs": "^6.5.0"
3333
},
3434
"devDependencies": {

test/fixtures/elm-package.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/fixtures/elm.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"summary": "Tests for `elm-webpack-loader`.",
3+
"type": "application",
4+
"source-directories": [
5+
".",
6+
"../other_elm_source_dir"
7+
],
8+
"elm-version": "0.19.0",
9+
"dependencies": {
10+
"direct": {
11+
"elm/browser": "1.0.0",
12+
"elm/core": "1.0.0",
13+
"elm/html": "1.0.0"
14+
},
15+
"indirect": {
16+
"elm/json": "1.0.0",
17+
"elm/time": "1.0.0",
18+
"elm/url": "1.0.0",
19+
"elm/virtual-dom": "1.0.0"
20+
}
21+
},
22+
"test-dependencies": {
23+
"direct": {},
24+
"indirect": {}
25+
}
26+
}

test/loader.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var fixturesDir = path.join(__dirname, 'fixtures');
88
var badSource = path.join(fixturesDir, 'Bad.elm');
99
var goodSource = path.join(fixturesDir, 'Good.elm');
1010
var goodDependency = path.join(fixturesDir, 'GoodDependency.elm');
11-
var elmPackage = path.join(fixturesDir, 'elm-package.json');
11+
var elmPackage = path.join(fixturesDir, 'elm.json');
1212
var otherElmSourceDir = path.join(__dirname, 'other_elm_source_dir');
1313

1414
var toString = Object.prototype.toString;
@@ -22,11 +22,11 @@ var hash = function (data) {
2222
};
2323

2424
var compile = function (filename) {
25-
return compiler.compileToString([filename], {yes: true, cwd: fixturesDir})
25+
return compiler.compileToString([filename], {cwd: fixturesDir})
2626
.then(function (data) {
2727
return data.toString();
2828
});
29-
}
29+
};
3030

3131
// Mock of webpack's loader context.
3232
var mock = function (source, query, opts, callback, watchMode, cwd) {
@@ -154,8 +154,9 @@ describe('async mode', function () {
154154
foo: 'bar'
155155
};
156156

157-
var callback = function () {
158-
assert.match(context.emittedWarning(), /unknown Elm compiler option/i);
157+
var callback = function (err) {
158+
assert.isPrototypeOf(err, Error);
159+
assert.match(err.message, /unknown Elm compiler option/i);
159160
done();
160161
};
161162

@@ -180,13 +181,13 @@ describe('async mode', function () {
180181
loader.call(context, goodSource);
181182
});
182183

183-
xit('emits errors for incorrect source files', function (done) {
184+
it('emits errors for incorrect source files', function (done) {
184185
var options = {
185186
cwd: fixturesDir
186187
};
187188

188-
var callback = function () {
189-
assert.match(context.emittedError(), /syntax problem/i);
189+
var callback = function (err) {
190+
assert.match(err.message, /parse error/i);
190191
done();
191192
};
192193

0 commit comments

Comments
 (0)