UNPKG

1.2 kBJavaScriptView Raw
1"use strict";
2
3const
4 Path = require( "path" ),
5 Util = require( "../lib/util" );
6
7describe( 'Module util', () => {
8 describe( 'function replaceDotsWithSlashes', () => {
9
10 /**
11 * Check if the input produces what was expected.
12 *
13 * @param {string} input - File name with full path.
14 * @param {string} expected - What was expected.
15 * @returns {undefined}
16 */
17 function check( input, expected ) {
18 const output = Util.replaceDotsWithSlashes( input );
19 expect( output ).toBe( expected.split( '/' ).join( Path.sep ) );
20 }
21
22 it( 'should not change modules without dots in the name', function () {
23 check( "foo/bar/my-super-module.js", "foo/bar/my-super-module.js" );
24 } );
25 it( 'should change modules with dots in the name', function () {
26 check( "foo/bar/my.super.module.js", "foo/bar/my/super/module.js" );
27 } );
28 it( 'should return non-strings verbatim', function () {
29 expect( Util.replaceDotsWithSlashes( null ) ).toBe( null );
30 expect( Util.replaceDotsWithSlashes( 3.14 ) ).toBe( 3.14 );
31 } );
32 } );
33} );
\No newline at end of file