File tree 2 files changed +9
-4
lines changed
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 1
1
import Bir from './bir.js'
2
2
export default Bir
3
+ export { BirError } from './error.js'
Original file line number Diff line number Diff line change 1
1
import t from 'tap'
2
- import Bir from '../src/index.js'
2
+ import Bir , { BirError } from '../src/index.js'
3
3
4
4
t . test ( 'search by REGON for example company' , async ( t ) => {
5
5
const bir = new Bir ( )
@@ -26,9 +26,13 @@ t.test('search fail for non existing company', async (t) => {
26
26
const bir = new Bir ( )
27
27
const searchNotExisting = async ( ) =>
28
28
await bir . search ( { regon : 'notExisting' } )
29
- await t . rejects ( searchNotExisting , {
30
- message : 'No data found for the specified search criteria' ,
31
- } )
29
+ try {
30
+ await searchNotExisting ( )
31
+ t . fail ( 'Should throw error when searching for a non-existing company' )
32
+ } catch ( err ) {
33
+ t . match ( err , { message : 'No data found for the specified search criteria' } )
34
+ t . ok ( err instanceof BirError , 'Error should be an instance of Error' )
35
+ }
32
36
t . end ( )
33
37
} )
34
38
You can’t perform that action at this time.
0 commit comments