2024-04-25 05:43:17 +03:00
|
|
|
import { expect } from 'vitest'
|
2024-08-13 04:53:07 +03:00
|
|
|
|
2024-03-18 01:49:55 +03:00
|
|
|
import { setPlatform } from '../../packages/core/src/platform.js'
|
2024-04-25 05:43:17 +03:00
|
|
|
import { buffersEqual } from '../../packages/core/src/utils/buffer-utils.js'
|
2024-03-18 01:49:55 +03:00
|
|
|
|
|
|
|
// @ts-expect-error no .env here
|
2024-04-25 05:25:56 +03:00
|
|
|
if (import.meta.env.TEST_ENV === 'browser' || import.meta.env.TEST_ENV === 'deno') {
|
2024-03-18 01:49:55 +03:00
|
|
|
setPlatform(new (await import('../../packages/web/src/platform.js')).WebPlatform())
|
|
|
|
} else {
|
2024-03-23 18:13:31 +03:00
|
|
|
setPlatform(new (await import('../../packages/node/src/common-internals-node/platform.js')).NodePlatform())
|
2024-04-25 05:43:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// consider Buffers equal to Uint8Arrays
|
|
|
|
expect.addEqualityTesters([
|
|
|
|
function (a, b) {
|
|
|
|
if (a instanceof Uint8Array && b instanceof Uint8Array) {
|
|
|
|
return buffersEqual(a, b)
|
|
|
|
}
|
2024-08-13 04:53:07 +03:00
|
|
|
},
|
|
|
|
])
|