Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Unified Diff: test/module_test.ts

Issue 2394683003: JS Interop Facade generation polish.
Patch Set: more cleanup Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/js_interop_test.ts ('k') | test/test_support.ts » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/module_test.ts
diff --git a/test/module_test.ts b/test/module_test.ts
index 12987f7bda4e61dcf886947b439fa05eece6a0eb..e7a372fba54a28796c591ddcbafddeff8cd43ab2 100644
--- a/test/module_test.ts
+++ b/test/module_test.ts
@@ -16,10 +16,10 @@ describe('imports', () => {
it('translates import star', () => {
expectTranslate('import * as foo from "z";').to.equal('import "package:z.dart" as foo;');
});
- it('allows import dart file from relative path', () => {
+ it('simplify import dart file imports with relative paths', () => {
expectTranslate('import x = require("./y")').to.equal('import "y.dart" as x;');
expectTranslate('import {x} from "./y"').to.equal('import "y.dart" show x;');
- expectTranslate('import {x} from "../y"').to.equal('import "../y.dart" show x;');
+ expectTranslate('import {x} from "../y"').to.equal('import "y.dart" show x;');
});
it('fails for renamed imports', () => {
expectErroneousCode('import {Foo as Bar} from "baz";')
@@ -51,6 +51,14 @@ class X {
it('allows named export declarations', () => {
expectTranslate('export {a, b} from "X";').to.equal('export "package:X.dart" show a, b;');
});
+ it('ignores named export declarations', () => {
+ expectTranslate(`declare module '../some_other_module' {
+ interface Foo { }
+ }`)
+ .to.equal(
+ '// Library augmentation not allowed by Dart. Ignoring augmentation of ../some_other_module');
+ });
+
it('fails for renamed exports', () => {
expectErroneousCode('export {Foo as Bar} from "baz";')
.to.throw(/import\/export renames are unsupported in Dart/);
@@ -62,18 +70,18 @@ class X {
() => { expectErroneousCode('export {} from "baz";').to.throw(/empty export list/); });
});
-describe('library name', () => {
+describe('module name', () => {
let transpiler: main.Transpiler;
let modTranspiler: ModuleTranspiler;
beforeEach(() => {
- transpiler = new main.Transpiler({failFast: true, generateLibraryName: true, basePath: '/a'});
+ transpiler = new main.Transpiler({failFast: true, moduleName: 'sample_module', basePath: '/a'});
modTranspiler = new ModuleTranspiler(
- transpiler, new FacadeConverter(transpiler, '', new NameRewriter(), false), true);
+ transpiler, new FacadeConverter(transpiler, '', new NameRewriter()), 'sample_module');
});
- it('adds a library name', () => {
+ it('adds module name', () => {
let results = translateSources(
- {'/a/b/c.ts': 'var x;'}, {failFast: true, generateLibraryName: true, basePath: '/a'});
- chai.expect(results['/a/b/c.ts']).to.equal(`@JS()
+ {'/a/b/c.ts': 'var x;'}, {failFast: true, moduleName: 'sample_module', basePath: '/a'});
+ chai.expect(results['/a/b/c.ts']).to.equal(`@JS("sample_module")
library b.c;
import "package:js/js.dart";
« no previous file with comments | « test/js_interop_test.ts ('k') | test/test_support.ts » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698