@@ -486,7 +486,7 @@ describe('Basic end-to-end Workflow', function () {
486486 expect ( indexHtml ) . to . include ( 'main.bundle.js' ) ;
487487 } ) ;
488488
489- it ( 'styles.css is added to main bundle' , function ( ) {
489+ it ( 'styles.css is added to styles bundle' , function ( ) {
490490 this . timeout ( 420000 ) ;
491491
492492 let stylesPath = path . join ( process . cwd ( ) , 'src' , 'styles.css' ) ;
@@ -495,10 +495,10 @@ describe('Basic end-to-end Workflow', function () {
495495
496496 sh . exec ( `${ ngBin } build` ) ;
497497
498- var mainBundlePath = path . join ( process . cwd ( ) , 'dist' , 'main .bundle.js' ) ;
499- var mainBundleContent = fs . readFileSync ( mainBundlePath , { encoding : 'utf8' } ) ;
498+ var stylesBundlePath = path . join ( process . cwd ( ) , 'dist' , 'styles .bundle.js' ) ;
499+ var stylesBundleContent = fs . readFileSync ( stylesBundlePath , { encoding : 'utf8' } ) ;
500500
501- expect ( mainBundleContent . includes ( testStyle ) ) . to . be . equal ( true ) ;
501+ expect ( stylesBundleContent . includes ( testStyle ) ) . to . be . equal ( true ) ;
502502 } ) ;
503503
504504 it ( 'styles.css supports css imports' , function ( ) {
@@ -520,6 +520,52 @@ describe('Basic end-to-end Workflow', function () {
520520 expect ( mainBundleContent . includes ( testStyle ) ) . to . be . equal ( true ) ;
521521 } ) ;
522522
523+ it ( 'build supports global styles and scripts' , function ( ) {
524+ this . timeout ( 420000 ) ;
525+
526+ sh . exec ( 'npm install bootstrap@next' , { silent : true } ) ;
527+
528+ const configFile = path . join ( process . cwd ( ) , 'angular-cli.json' ) ;
529+ let configContent = fs . readFileSync ( configFile , { encoding : 'utf8' } ) ;
530+ configContent . replace ( '\"styles.css\"' , `
531+ "styles.css",
532+ "../node_modules/bootstrap/dist/css/bootstrap.css"
533+ ` ) ;
534+
535+ configContent . replace ( '\"scripts\": [],' , `
536+ "scripts": [
537+ "../node_modules/jquery/dist/jquery.js",
538+ "../node_modules/tether/dist/js/tether.js",
539+ "../node_modules/bootstrap/dist/js/bootstrap.js"
540+ ],
541+ ` ) ;
542+
543+ fs . writeFileSync ( configFile , configContent , 'utf8' ) ;
544+
545+ sh . exec ( `${ ngBin } build` ) ;
546+
547+ // checking for strings that are part of the included files
548+ const stylesBundlePath = path . join ( process . cwd ( ) , 'dist' , 'styles.bundle.js' ) ;
549+ const stylesBundleContent = fs . readFileSync ( stylesBundlePath , { encoding : 'utf8' } ) ;
550+ expect ( stylesBundleContent . includes ( '* Bootstrap ' ) ) . to . be . equal ( true ) ;
551+
552+ const scriptsBundlePath = path . join ( process . cwd ( ) , 'dist' , 'styles.bundle.js' ) ;
553+ const scriptsBundleContent = fs . readFileSync ( scriptsBundlePath , { encoding : 'utf8' } ) ;
554+ expect ( scriptsBundleContent . includes ( '* jQuery JavaScript' ) ) . to . be . equal ( true ) ;
555+ expect ( scriptsBundleContent . includes ( '/*! tether ' ) ) . to . be . equal ( true ) ;
556+ expect ( scriptsBundleContent . includes ( '* Bootstrap ' ) ) . to . be . equal ( true ) ;
557+ } ) ;
558+
559+ it ( 'loads inline, styles, scripts and main in that order' , function ( ) {
560+ const indexPath = path . join ( process . cwd ( ) , 'dist' , 'index.html' ) ;
561+ const indexContent = fs . readFileSync ( indexPath , { encoding : 'utf8' } ) ;
562+ let scriptTags = '<script type="text/javascript" src="inline.js"></script>' +
563+ '<script type="text/javascript" src="styles.bundle.js"></script>' +
564+ '<script type="text/javascript" src="scripts.bundle.js">' +
565+ '<script type="text/javascript" src="main.bundle.js"></script>'
566+ expect ( indexContent . includes ( scriptTags ) ) . to . be . equal ( true ) ;
567+ } ) ;
568+
523569 it ( 'Serve and run e2e tests on dev environment' , function ( ) {
524570 this . timeout ( 240000 ) ;
525571
0 commit comments