@@ -486,7 +486,7 @@ describe('Basic end-to-end Workflow', function () {
486
486
expect ( indexHtml ) . to . include ( 'main.bundle.js' ) ;
487
487
} ) ;
488
488
489
- it ( 'styles.css is added to main bundle' , function ( ) {
489
+ it ( 'styles.css is added to styles bundle' , function ( ) {
490
490
this . timeout ( 420000 ) ;
491
491
492
492
let stylesPath = path . join ( process . cwd ( ) , 'src' , 'styles.css' ) ;
@@ -495,10 +495,10 @@ describe('Basic end-to-end Workflow', function () {
495
495
496
496
sh . exec ( `${ ngBin } build` ) ;
497
497
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' } ) ;
500
500
501
- expect ( mainBundleContent . includes ( testStyle ) ) . to . be . equal ( true ) ;
501
+ expect ( stylesBundleContent . includes ( testStyle ) ) . to . be . equal ( true ) ;
502
502
} ) ;
503
503
504
504
it ( 'styles.css supports css imports' , function ( ) {
@@ -508,16 +508,62 @@ describe('Basic end-to-end Workflow', function () {
508
508
let testStyle = 'body { background-color: blue; }' ;
509
509
fs . writeFileSync ( importedStylePath , testStyle , 'utf8' ) ;
510
510
511
- let stylesPath = path . join ( process . cwd ( ) , 'src' , 'style .css' ) ;
512
- let importStyle = '@import \'./imported-style .css\';' ;
511
+ let stylesPath = path . join ( process . cwd ( ) , 'src' , 'styles .css' ) ;
512
+ let importStyle = '@import \'./imported-styles .css\';' ;
513
513
fs . writeFileSync ( stylesPath , importStyle , 'utf8' ) ;
514
514
515
515
sh . exec ( `${ ngBin } build` ) ;
516
516
517
- var mainBundlePath = path . join ( process . cwd ( ) , 'dist' , 'main.bundle.js' ) ;
518
- var mainBundleContent = fs . readFileSync ( mainBundlePath , { encoding : 'utf8' } ) ;
517
+ var stylesBundlePath = path . join ( process . cwd ( ) , 'dist' , 'styles.bundle.js' ) ;
518
+ var stylesBundleContent = fs . readFileSync ( stylesBundlePath , { encoding : 'utf8' } ) ;
519
+
520
+ expect ( stylesBundleContent ) . to . include ( testStyle ) ;
521
+ } ) ;
522
+
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 originalConfigContent = fs . readFileSync ( configFile , { encoding : 'utf8' } ) ;
530
+ let configContent = originalConfigContent . replace ( '"styles.css"' , `
531
+ "styles.css",
532
+ "../node_modules/bootstrap/dist/css/bootstrap.css"
533
+ ` ) . replace ( '"scripts": [],' , `
534
+ "scripts": [
535
+ "../node_modules/jquery/dist/jquery.js",
536
+ "../node_modules/tether/dist/js/tether.js",
537
+ "../node_modules/bootstrap/dist/js/bootstrap.js"
538
+ ],
539
+ ` ) ;
540
+
541
+ fs . writeFileSync ( configFile , configContent , 'utf8' ) ;
542
+
543
+ sh . exec ( `${ ngBin } build` ) ;
519
544
520
- expect ( mainBundleContent . includes ( testStyle ) ) . to . be . equal ( true ) ;
545
+ // checking for strings that are part of the included files
546
+ const stylesBundlePath = path . join ( process . cwd ( ) , 'dist' , 'styles.bundle.js' ) ;
547
+ const stylesBundleContent = fs . readFileSync ( stylesBundlePath , { encoding : 'utf8' } ) ;
548
+ expect ( stylesBundleContent ) . to . include ( '* Bootstrap ' ) ;
549
+
550
+ const scriptsBundlePath = path . join ( process . cwd ( ) , 'dist' , 'scripts.bundle.js' ) ;
551
+ const scriptsBundleContent = fs . readFileSync ( scriptsBundlePath , { encoding : 'utf8' } ) ;
552
+ expect ( scriptsBundleContent ) . to . include ( '* jQuery JavaScript' ) ;
553
+ expect ( scriptsBundleContent ) . to . include ( '/*! tether ' ) ;
554
+ expect ( scriptsBundleContent ) . to . include ( '* Bootstrap ' ) ;
555
+
556
+ // check the scripts are loaded in the correct order
557
+ const indexPath = path . join ( process . cwd ( ) , 'dist' , 'index.html' ) ;
558
+ const indexContent = fs . readFileSync ( indexPath , { encoding : 'utf8' } ) ;
559
+ let scriptTags = '<script type="text/javascript" src="inline.js"></script>' +
560
+ '<script type="text/javascript" src="styles.bundle.js"></script>' +
561
+ '<script type="text/javascript" src="scripts.bundle.js"></script>' +
562
+ '<script type="text/javascript" src="main.bundle.js"></script>'
563
+ expect ( indexContent ) . to . include ( scriptTags ) ;
564
+
565
+ // restore config
566
+ fs . writeFileSync ( configFile , originalConfigContent , 'utf8' ) ;
521
567
} ) ;
522
568
523
569
it ( 'Serve and run e2e tests on dev environment' , function ( ) {
0 commit comments