File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ import xmock from 'xmock' ;
2+
3+ import mapSpec , { plugins } from '../../src/specmap' ;
4+
5+ const { externalValue } = plugins ;
6+
7+ describe ( 'externalValue' , ( ) => {
8+ let xapp ;
9+
10+ beforeAll ( ( ) => {
11+ xapp = xmock ( ) ;
12+ } ) ;
13+
14+ afterAll ( ( ) => {
15+ xapp . restore ( ) ;
16+ } ) ;
17+
18+ beforeEach ( ( ) => {
19+ externalValue . clearCache ( )
20+ } ) ;
21+
22+ describe ( 'ExternalValueError' , ( ) => {
23+ test ( 'should contain the externalValue error details' , ( ) => {
24+ try {
25+ throw new externalValue . ExternalValueError ( 'Probe' , {
26+ externalValue : 'http://test.com/probe' ,
27+ fullPath : "probe" ,
28+ } ) ;
29+ } catch ( e ) {
30+ expect ( e . toString ( ) ) . toEqual ( 'ExternalValueError: Probe' ) ;
31+ expect ( e . externalValue ) . toEqual ( 'http://test.com/probe' ) ;
32+ expect ( e . fullPath ) . toEqual ( "probe" ) ;
33+ }
34+ } ) ;
35+ test ( '.wrapError should wrap an error in ExternalValueError' , ( ) => {
36+ try {
37+ throw externalValue . wrapError ( new Error ( 'hi' ) , {
38+ externalValue : 'http://test.com/probe' ,
39+ fullPath : "probe" ,
40+ } ) ;
41+ } catch ( e ) {
42+ expect ( e . message ) . toMatch ( / e x t e r n a l V a l u e / ) ;
43+ expect ( e . message ) . toMatch ( / h i / ) ;
44+ expect ( e . externalValue ) . toEqual ( 'http://test.com/probe' ) ;
45+ expect ( e . fullPath ) . toEqual ( "probe" ) ;
46+ }
47+ } ) ;
48+ } ) ;
49+
50+ } ) ;
You can’t perform that action at this time.
0 commit comments