File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ class Platform {
55 try {
66 return map [ Platform . OS ] ( ) ;
77 } catch ( error ) {
8- return map [ 'default' ] ( ) ;
8+ let defaultCallback = map [ 'default' ] ;
9+ return defaultCallback ? defaultCallback ( ) : undefined ;
910 }
1011 }
1112
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ describe('Platform', function(){
2424 linux : ( ) => 'linux' ,
2525 default : ( ) => 'bummer'
2626 } ;
27+ let noDefaultData = {
28+ darwin : ( ) => 'darwin' ,
29+ win32 : ( ) => 'win32' ,
30+ linux : ( ) => 'linux'
31+ } ;
2732
2833 it ( 'returns value of opject\'s property named the same as current platform' , function ( ) {
2934 sandbox . stub ( Platform , 'getOS' ) . returns ( 'win32' ) ;
@@ -39,6 +44,11 @@ describe('Platform', function(){
3944 expect ( Platform . identify ( data ) ) . to . be . equal ( 'bummer' ) ;
4045 } ) ;
4146
47+ it ( 'returns undefined if there no propyrty with current platform name and no default provided' , function ( ) {
48+ sandbox . stub ( Platform , 'getOS' ) . returns ( 'ps/2' ) ;
49+ expect ( Platform . identify ( noDefaultData ) ) . to . be . equal ( undefined ) ;
50+ } ) ;
51+
4252 } ) ;
4353
4454 describe ( 'PATH' , function ( ) {
You can’t perform that action at this time.
0 commit comments