Skip to content

Commit d7bb0fd

Browse files
[qa] Some tests for import/export.
1 parent 790a181 commit d7bb0fd

File tree

10 files changed

+41
-10
lines changed

10 files changed

+41
-10
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
**/*.pyc
22
*.ls.js
3+
.*.swp
34
.DS_Store
45
node_modules
56
app.db
67
/src/browse-sqlite.html
78
/src/old
89
/dist
910
/.cache
10-
/build
11+
/build
12+
/tests/**/build

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<head>
44
<meta charset="utf-8">
55
<script src="kremlin://src/build/testbed.ts"></script>
6-
<script>var k = require('./plug').default.watch({window, main: 'index.html'});</script>
6+
<script>
7+
var k = require('./plug').default.watch({window,
8+
main: ['index.html', 'src/plug.ts', 'src/cli.ts']});
9+
</script>
710
</head>
811
<body>
912

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"acorn-walk": "^7.2.0",
1919
"chokidar": "^3.4.1",
2020
"coffeescript": "^2.5.1",
21-
"commander": "^3.0.2",
21+
"commander": "^6.0.0",
2222
"find-up": "^4.1.0",
2323
"glob": "^7.1.6",
2424
"jison": "^0.4.18",

src/build/testbed.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ function testbed() {
2020
var projects: {[name: string]: ProjectDefinition} = {
2121
kremlin: {
2222
wd: '.',
23-
main: ['index.kremlin.html', 'src/plug.ts', 'src/cli.ts']
23+
main: ['index.html', 'src/plug.ts', 'src/cli.ts']
2424
},
2525
author: {
2626
wd: '/Users/corwin/var/workspace/Web.Author',
2727
main: 'src/hub.ls'
28+
},
29+
'tests/import-export': {
30+
wd: 'tests/import-export',
31+
main: 'index.js'
2832
}
2933
};
3034

31-
var proj = ProjectDefinition.normalize(projects['kremlin']);
35+
var proj = ProjectDefinition.normalize(projects['tests/import-export']);
3236

3337
var targets = [].concat(...proj.main.map(t => t.input));
3438

src/plug.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Kremlin {
2222
}
2323

2424
prepare(proj: ProjectDefinition = this.proj || {}) {
25-
var b = new Builder(proj);
25+
var b = new Builder(proj, this.builder && this.builder.env);
2626
this.proj = b.proj;
2727
b.env.report = new ReportToConsole(this.console);
2828
this.builder = b;
@@ -111,7 +111,8 @@ class Kremlin {
111111
_ignoreFuncs: ((filename: string) => boolean)[] = [
112112
(filename) => filename.split(path.sep).some(
113113
(x) => x[0] == '.' || x == 'node_modules' || x == 'bower_components'),
114-
(filename) => !!/^\d+$/.exec(filename)
114+
(filename) => !!/^\d+$/.exec(filename),
115+
(filename) => this.proj && filename.startsWith(this.proj.buildDir)
115116
];
116117
}
117118

tests/import-export/export-decl.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
if (! Array.isArray) {
3+
throw new Error();
4+
}
5+
6+
export const isArray = Array.isArray;

tests/import-export/export-default.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { writeFileSync, readFileSync } from 'fs';
2+
3+
class DefExport { }
4+
5+
export default {
6+
instance: new DefExport(),
7+
directives: {
8+
writeFileSync,
9+
read: readFileSync
10+
}
11+
}

tests/import-export/export-from.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './export-default';

tests/import-export/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import './export-from';
2+
3+
import './export-decl';

0 commit comments

Comments
 (0)