@@ -23,7 +23,7 @@ describe('Utils', () => {
2323 expect ( Utils . stringify ( [ { one : afoo , two : afoo } ] ) ) . toBe ( '[{"one":{"a":"foo"}}]' ) ;
2424 } ) ;
2525
26- it ( 'should exclude properties ', ( ) => {
26+ describe ( 'stringify ', ( ) => {
2727 var user :any = {
2828 id :1 ,
2929 name : 'Blake' ,
@@ -37,11 +37,27 @@ describe('Utils', () => {
3737 }
3838 } ;
3939
40- expect ( Utils . stringify ( user ) ) . toBe ( JSON . stringify ( user ) ) ;
41- expect ( Utils . stringify ( user , [ 'pAssword' ] ) ) . toBe ( '{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}' ) ;
42- expect ( Utils . stringify ( user , [ '*password' ] ) ) . toBe ( '{"id":1,"name":"Blake","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}' ) ;
43- expect ( Utils . stringify ( user , [ 'password*' ] ) ) . toBe ( '{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","customValue":"Password","value":{}}' ) ;
44- expect ( Utils . stringify ( user , [ '*password*' ] ) ) . toBe ( '{"id":1,"name":"Blake","customValue":"Password","value":{}}' ) ;
40+ it ( 'should behave like JSON.stringify' , ( ) => {
41+ expect ( Utils . stringify ( user ) ) . toBe ( JSON . stringify ( user ) ) ;
42+ } ) ;
43+
44+ describe ( 'with exclude pattern' , ( ) => {
45+ it ( 'pAssword' , ( ) => {
46+ expect ( Utils . stringify ( user , [ 'pAssword' ] ) ) . toBe ( '{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}' ) ;
47+ } ) ;
48+
49+ it ( '*password' , ( ) => {
50+ expect ( Utils . stringify ( user , [ '*password' ] ) ) . toBe ( '{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","customValue":"Password","value":{}}' ) ;
51+ } ) ;
52+
53+ it ( 'password*' , ( ) => {
54+ expect ( Utils . stringify ( user , [ 'password*' ] ) ) . toBe ( '{"id":1,"name":"Blake","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}' ) ;
55+ } ) ;
56+
57+ it ( '*password*' , ( ) => {
58+ expect ( Utils . stringify ( user , [ '*password*' ] ) ) . toBe ( '{"id":1,"name":"Blake","customValue":"Password","value":{}}' ) ;
59+ } ) ;
60+ } ) ;
4561 } ) ;
4662
4763 it ( 'should stringify array' , ( ) => {
0 commit comments