@@ -3,8 +3,10 @@ let path = require('path')
33let phpLoader = require ( './../php-loader' )
44
55describe ( 'it should load php language files' , function ( ) {
6+ const loaderMock = { addDependency : ( ) => { } } ;
7+
68 it ( 'should load regular php translation' , function ( ) {
7- let content = phpLoader . execute ( './test/fixtures/php' , { } ) ;
9+ let content = phpLoader . execute ( './test/fixtures/php' , { } , loaderMock ) ;
810
911 assert . deepEqual ( content . en , {
1012 translation : {
@@ -17,7 +19,7 @@ describe('it should load php language files', function () {
1719 } ) ;
1820
1921 it ( 'should load both languages' , function ( ) {
20- let content = phpLoader . execute ( './test/fixtures/php' , { } ) ;
22+ let content = phpLoader . execute ( './test/fixtures/php' , { } , loaderMock ) ;
2123
2224 assert . deepEqual ( content . en , {
2325 translation : {
@@ -41,7 +43,7 @@ describe('it should load php language files', function () {
4143 it ( 'should be able to replace parameters' , function ( ) {
4244 let content = phpLoader . execute ( './test/fixtures/php-with-parameters' , {
4345 parameters : '{{ $1 }}'
44- } ) ;
46+ } , loaderMock ) ;
4547
4648 assert . deepEqual ( content . en , {
4749 validation : {
@@ -51,7 +53,7 @@ describe('it should load php language files', function () {
5153 } ) ;
5254
5355 it ( 'should be able to load nested folders' , function ( ) {
54- let content = phpLoader . execute ( './test/fixtures/php-with-nested-folders' , { } ) ;
56+ let content = phpLoader . execute ( './test/fixtures/php-with-nested-folders' , { } , loaderMock ) ;
5557
5658 assert . deepEqual ( content . en , {
5759 validation : {
@@ -68,7 +70,7 @@ describe('it should load php language files', function () {
6870 let namespace = 'test' ;
6971 let content = phpLoader . execute ( './test/fixtures/php-with-namespace' , {
7072 namespace : namespace ,
71- } ) ;
73+ } , loaderMock ) ;
7274
7375 assert . deepEqual ( content . en [ namespace ] , {
7476 validation : {
@@ -82,7 +84,7 @@ describe('it should load php language files', function () {
8284 let content = phpLoader . execute ( './test/fixtures/php-with-namespace-parameters' , {
8385 namespace : namespace ,
8486 parameters : '{{ $1 }}'
85- } ) ;
87+ } , loaderMock ) ;
8688
8789 assert . deepEqual ( content . en [ namespace ] , {
8890 validation : {
@@ -92,7 +94,7 @@ describe('it should load php language files', function () {
9294 } ) ;
9395
9496 it ( 'should not fail execution with invalid file' , function ( ) {
95- let content = phpLoader . execute ( './test/fixtures/php-with-one-invalid-file' , { } ) ;
97+ let content = phpLoader . execute ( './test/fixtures/php-with-one-invalid-file' , { } , loaderMock ) ;
9698
9799 assert . deepEqual ( content . en , {
98100 translation : {
@@ -103,4 +105,17 @@ describe('it should load php language files', function () {
103105 }
104106 } ) ;
105107 } ) ;
108+
109+ it ( 'should register translation files as dependencies for live reloading' , function ( ) {
110+ let dependency = '' ;
111+ const loaderMock = { addDependency : ( dep ) => {
112+ dependency = dep ;
113+ } } ;
114+
115+ phpLoader . execute ( './test/fixtures/php-with-namespace' , { } , loaderMock ) ;
116+
117+ const expected = '/test/fixtures/php-with-namespace/en/validation.php' ;
118+ const actual = dependency . substring ( dependency . length - expected . length ) ;
119+ assert . deepStrictEqual ( actual . split ( path . sep ) , expected . split ( '/' ) ) ;
120+ } ) ;
106121} ) ;
0 commit comments