import { tap, expect } from '@git.zone/tstest/tapbundle'; import * as skr from '../ts/index.js'; tap.test('should export all required classes and types', async () => { expect(skr.Account).toBeTypeOf('function'); expect(skr.Transaction).toBeTypeOf('function'); expect(skr.JournalEntry).toBeTypeOf('function'); expect(skr.ChartOfAccounts).toBeTypeOf('function'); expect(skr.Ledger).toBeTypeOf('function'); expect(skr.Reports).toBeTypeOf('function'); expect(skr.SkrApi).toBeTypeOf('function'); expect(skr.SKR03_ACCOUNTS).toBeArray(); expect(skr.SKR04_ACCOUNTS).toBeArray(); }); tap.test('should have correct number of SKR03 accounts', async () => { expect(skr.SKR03_ACCOUNTS.length).toBeGreaterThan(50); expect(skr.SKR03_ACCOUNTS[0].skrType).toEqual('SKR03'); }); tap.test('should have correct number of SKR04 accounts', async () => { expect(skr.SKR04_ACCOUNTS.length).toBeGreaterThan(50); expect(skr.SKR04_ACCOUNTS[0].skrType).toEqual('SKR04'); }); tap.test('should have valid account structure for SKR03', async () => { const firstAccount = skr.SKR03_ACCOUNTS[0]; expect(firstAccount.accountNumber).toBeTypeofString(); expect(firstAccount.accountNumber.length).toEqual(4); expect(firstAccount.accountName).toBeTypeofString(); expect(firstAccount.accountClass).toBeTypeofNumber(); expect(firstAccount.accountType).toMatch( /^(asset|liability|equity|revenue|expense)$/, ); }); tap.test('should have valid account structure for SKR04', async () => { const firstAccount = skr.SKR04_ACCOUNTS[0]; expect(firstAccount.accountNumber).toBeTypeofString(); expect(firstAccount.accountNumber.length).toEqual(4); expect(firstAccount.accountName).toBeTypeofString(); expect(firstAccount.accountClass).toBeTypeofNumber(); expect(firstAccount.accountType).toMatch( /^(asset|liability|equity|revenue|expense)$/, ); }); tap.test('should have account classes 0-9 in SKR03', async () => { const classes = new Set(skr.SKR03_ACCOUNTS.map((a) => a.accountClass)); expect(classes.size).toBeGreaterThan(5); // Check that we have accounts in multiple classes for (let i = 0; i <= 9; i++) { const accountsInClass = skr.SKR03_ACCOUNTS.filter( (a) => a.accountClass === i, ); if (accountsInClass.length > 0) { expect(accountsInClass[0].accountNumber[0]).toEqual(i.toString()); } } }); tap.test('should have account classes 0-9 in SKR04', async () => { const classes = new Set(skr.SKR04_ACCOUNTS.map((a) => a.accountClass)); expect(classes.size).toBeGreaterThan(5); // Check that we have accounts in multiple classes for (let i = 0; i <= 9; i++) { const accountsInClass = skr.SKR04_ACCOUNTS.filter( (a) => a.accountClass === i, ); if (accountsInClass.length > 0) { expect(accountsInClass[0].accountNumber[0]).toEqual(i.toString()); } } }); export default tap.start();