@Test public void dependendLibrariesAreBundled() throws Exception { given(thirdpartyLib) .containsFileWithContents( "thirdparty-lib.manifest", "depends: " + thirdpartyLib2.getName() + "\n" + "exports: lib") .and(thirdpartyLib) .containsFiles("lib1-file.js") .and(thirdpartyLib2) .containsFileWithContents("thirdparty-lib.manifest", "exports: lib") .and(thirdpartyLib2) .containsFiles("lib2-file.js") .and(aspect) .indexPageHasContent("require('" + thirdpartyLib.getName() + "')"); when(aspect).requestReceivedInDev("js/dev/combined/bundle.js", pageResponse); then(pageResponse).containsOrderedTextFragments("lib2-file.js", "lib1-file.js"); }
@Test public void libBundleRequestOnlyContainsFilesForTheLib() throws Exception { given(thirdpartyLib) .containsFileWithContents( "thirdparty-lib.manifest", "depends: " + thirdpartyLib2.getName() + "\n" + "exports: lib") .and(thirdpartyLib) .containsFiles("lib1-file1.js", "lib1-file2.js") .and(thirdpartyLib2) .containsFileWithContents("thirdparty-lib.manifest", "exports: lib") .and(thirdpartyLib2) .containsFiles("lib2-file1.js") .and(aspect) .indexPageHasContent( "<@thirdparty.bundle@/>\n" + "require('" + thirdpartyLib.getName() + "')"); when(aspect).requestReceivedInDev("thirdparty/thirdparty-lib/bundle.js", pageResponse); then(pageResponse) .containsOrderedTextFragments("lib1-file1.js", "lib1-file2.js") .and(pageResponse) .doesNotContainText("lib2-file1.js"); }
@Test public void allJsFilesAreIncludedIfManifestDoesntListThem() throws Exception { given(thirdpartyLib) .containsFileWithContents("thirdparty-lib.manifest", "exports: lib") .and(thirdpartyLib) .containsFiles("file1.js", "file2.js") .and(aspect) .indexPageHasContent( "<@thirdparty.bundle@/>\n" + "require('" + thirdpartyLib.getName() + "')"); when(aspect).requestReceivedInDev("thirdparty/thirdparty-lib/bundle.js", pageResponse); then(pageResponse).containsOrderedTextFragments("file1.js", "file2.js"); }
@Test public void allSettingsAreOptional() throws Exception { given(thirdpartyLib) .containsFileWithContents("thirdparty-lib.manifest", "") .and(thirdpartyLib) .containsFiles("file1.js") .and(aspect) .indexPageHasContent( "<@thirdparty.bundle@/>\n" + "require('" + thirdpartyLib.getName() + "')"); when(aspect).requestReceivedInDev("thirdparty/thirdparty-lib/bundle.js", pageResponse); then(pageResponse).containsText("file1.js").and(exceptions).verifyNoOutstandingExceptions(); }
@Test public void singleModuleRequestContainsAllFilesForTheModule() throws Exception { given(thirdpartyLib) .containsFileWithContents( "thirdparty-lib.manifest", "js: file1.js, file2.js\n" + "exports: lib") .and(thirdpartyLib) .containsFiles("file1.js", "file2.js") .and(aspect) .indexPageHasContent( "<@thirdparty.bundle@/>\n" + "require('" + thirdpartyLib.getName() + "')"); when(aspect).requestReceivedInDev("thirdparty/thirdparty-lib/bundle.js", pageResponse); then(pageResponse).containsOrderedTextFragments("file1.js", "file2.js"); }
@Test public void fileNamesThatEndWithADesiredFileNameAreNotIncluded() throws Exception { given(thirdpartyLib) .containsFileWithContents("thirdparty-lib.manifest", "js: lib.js\n" + "exports: lib") .and(thirdpartyLib) .containsFiles("lib.js", "X-lib.js", "Y-lib.js") .and(aspect) .indexPageHasContent( "<@thirdparty.bundle@/>\n" + "require('" + thirdpartyLib.getName() + "')"); when(aspect).requestReceivedInDev("thirdparty/bundle.js", pageResponse); then(pageResponse) .containsText("lib.js") .and(pageResponse) .doesNotContainText("X-lib.js") .and(pageResponse) .doesNotContainText("Y-lib.js"); }
@Test public void bundleRequestContainsAllModuleBundles() throws Exception { given(thirdpartyLib) .containsFileWithContents( "thirdparty-lib.manifest", "depends: " + thirdpartyLib2.getName() + "\n" + "exports: lib") .and(thirdpartyLib) .containsFiles("lib1-file1.js", "lib1-file2.js") .and(thirdpartyLib2) .containsFileWithContents("thirdparty-lib.manifest", "exports: lib\n" + "exports: lib") .and(thirdpartyLib2) .containsFiles("lib2-file1.js") .and(aspect) .indexPageRequires(thirdpartyLib); when(aspect).requestReceivedInDev("thirdparty/bundle.js", pageResponse); then(pageResponse).containsOrderedTextFragments("lib2-file1", "lib1-file1", "lib1-file2"); }
@Test public void dependendSourceModulesAreBundled() throws Exception { given(thirdpartyLib) .containsFileWithContents( "thirdparty-lib.manifest", "depends: lib/Class\n" + "exports: lib") .and(thirdpartyLib) .containsFiles("lib1-file.js") .and(thirdpartyLib2) .containsFileWithContents("br-lib.conf", "requirePrefix: lib") .and(thirdpartyLib2) .containsFiles("src/lib/Class.js") .and(aspect) .indexPageHasContent("require('" + thirdpartyLib.getName() + "')"); when(aspect).requestReceivedInDev("js/dev/combined/bundle.js", pageResponse); then(pageResponse) .containsOrderedTextFragments( "lib1-file.js", "lib/Class.js"); // the order here is correct, thirdparty content always appears before // other types }
@Test public void onlyWhatsInTheManifestIsLoaded_ResourcesInTheLibAreNotTreatedAsSeedFiles() throws Exception { given(thirdpartyLib) .containsFileWithContents("thirdparty-lib.manifest", "js: file1.js\n" + "exports: lib") .and(thirdpartyLib) .containsFile("file1.js") .and(thirdpartyLib) .containsFileWithContents("ingoredFile.js", "require('appns.class1')\n") .and(thirdpartyLib) .containsFileWithContents("ingoredFile.html", "appns.class1\n") .and(thirdpartyLib) .containsFileWithContents("ingoredFile.xml", "appns.class1'") .and(aspect) .hasClass("appns/class1") .and(aspect) .indexPageHasContent("require('" + thirdpartyLib.getName() + "')"); when(aspect).requestReceivedInDev("js/dev/combined/bundle.js", pageResponse); then(pageResponse) .containsText("file1.js") .and(pageResponse) .doesNotContainText("appns.class1"); }