Skip to content

Commit 21bb2e7

Browse files
committed
export BirError
1 parent baa6dd3 commit 21bb2e7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import Bir from './bir.js'
22
export default Bir
3+
export { BirError } from './error.js'

test/bir.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import t from 'tap'
2-
import Bir from '../src/index.js'
2+
import Bir, { BirError } from '../src/index.js'
33

44
t.test('search by REGON for example company', async (t) => {
55
const bir = new Bir()
@@ -26,9 +26,13 @@ t.test('search fail for non existing company', async (t) => {
2626
const bir = new Bir()
2727
const searchNotExisting = async () =>
2828
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+
}
3236
t.end()
3337
})
3438

0 commit comments

Comments
 (0)