use of com.vaadin.flow.server.frontend.FrontendUtils.IMPORTS_NAME in project flow by vaadin.
the class UpdateThemedImportsTest method setup.
@Before
public void setup() throws Exception {
File tmpRoot = temporaryFolder.getRoot();
frontendDirectory = new File(tmpRoot, DEFAULT_FRONTEND_DIR);
nodeModulesPath = new File(tmpRoot, NODE_MODULES);
generatedPath = new File(tmpRoot, Paths.get(TARGET, DEFAULT_GENERATED_DIR).toString());
importsFile = new File(generatedPath, IMPORTS_NAME);
Assert.assertTrue(nodeModulesPath.mkdirs());
createImport("./src/subfolder/sub-template.js", "");
createImport("./src/client-side-template.js", "import 'xx' from './subfolder/sub-template.js';" + "import '@vaadin/vaadin-button/src/vaadin-button.js'");
createImport("./src/client-side-no-themed-template.js", "");
createImport("./src/main-template.js", "import 'xx' from './client-side-template.js';" + "import \"./client-side-no-themed-template.js\";" + "import './src/wrong-themed-template.js';" + "import '@vaadin/vaadin-button/src/vaadin-button.js'");
// create themed modules
createImport("./theme/myTheme/subfolder/sub-template.js", "");
createImport("./theme/myTheme/client-side-template.js", "");
createImport("./theme/myTheme/main-template.js", "");
// wrong-themed-template.js should not be resolved inside node_modules.
// It should be searched only inside frontend directory
createImport("theme/myTheme/wrong-themed-template.js", "");
// create css files to avoid exception when files not found during the
// test
createImport("./foo.css", "");
createImport("@vaadin/vaadin-mixed-component/bar.css", "");
// make external component's module and its themed version
createImport("@vaadin/vaadin-button/src/vaadin-button.js", "");
createImport("@vaadin/vaadin-button/theme/myTheme/vaadin-button.js", "");
ClassFinder finder = getClassFinder();
FrontendDependencies deps = new FrontendDependencies(finder) {
@Override
public List<String> getModules() {
return Stream.of("./src/main-template.js").collect(Collectors.toList());
}
@Override
public Set<String> getScripts() {
return Collections.emptySet();
}
@Override
public AbstractTheme getTheme() {
return new MyTheme();
}
@Override
public ThemeDefinition getThemeDefinition() {
return new ThemeDefinition(MyTheme.class, "", "");
}
};
updater = new TaskUpdateImports(finder, deps, cf -> null, tmpRoot, generatedPath, frontendDirectory, null, null, false, TARGET, true, false, Mockito.mock(FeatureFlags.class));
}
use of com.vaadin.flow.server.frontend.FrontendUtils.IMPORTS_NAME in project flow by vaadin.
the class AbstractNodeUpdateImportsTest method setup.
@Before
public void setup() throws Exception {
File tmpRoot = temporaryFolder.getRoot();
logger = new MockLogger();
frontendDirectory = new File(tmpRoot, DEFAULT_FRONTEND_DIR);
nodeModulesPath = new File(tmpRoot, NODE_MODULES);
generatedPath = new File(tmpRoot, Paths.get(TARGET, DEFAULT_GENERATED_DIR).toString());
importsFile = new File(generatedPath, IMPORTS_NAME);
ClassFinder classFinder = getClassFinder();
updater = new TaskUpdateImports(classFinder, getScanner(classFinder), finder -> null, tmpRoot, generatedPath, frontendDirectory, null, null, false, TARGET, true, false, Mockito.mock(FeatureFlags.class)) {
@Override
Logger log() {
return logger;
}
};
assertTrue(nodeModulesPath.mkdirs());
createExpectedImports(frontendDirectory, nodeModulesPath);
assertTrue(new File(nodeModulesPath, FLOW_NPM_PACKAGE_NAME + "ExampleConnector.js").exists());
}
Aggregations