Files
klz-cables.com/.pnpm-store/v10/files/fe/3bdcb6da564a9770d0b361ad20b5521daafbeaf31f9240dd69687943b83174d9232e63dd7c3942d66696176d3c01dbae037783916bbf55f351a35b5d81a2cf
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

122 lines
4.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/// <reference path="../objectid.d.ts" />
import ObjectID from '../objectid';
// ----------------------------------------------------------------------------
// setup test data
const time:number = 1414093117;
const array:number[] = [ 84, 73, 90, 217, 76, 147, 71, 33, 237, 231, 109, 144 ];
const buffer:Buffer = new Buffer([84, 73, 90, 217, 76, 147, 71, 33, 237, 231, 109, 144 ]);
const hexString:string = "54495ad94c934721ede76d90";
const idString:string = "TIZÙL“G!íçm";
// ----------------------------------------------------------------------------
// should construct with no arguments
let oid = new ObjectID();
// ----------------------------------------------------------------------------
// should have an `id` property
oid.id;
// ----------------------------------------------------------------------------
// should have a `str` property
oid.str;
// ----------------------------------------------------------------------------
// should construct with a `time` argument
oid = new ObjectID(time);
// ----------------------------------------------------------------------------
// should construct with an `array` argument
oid = new ObjectID(array);
// ----------------------------------------------------------------------------
// should construct with a `buffer` argument
oid = new ObjectID(buffer);
// ----------------------------------------------------------------------------
// should construct with a `hexString` argument
oid = new ObjectID(hexString);
// ----------------------------------------------------------------------------
// should construct with a `idString` argument
oid = new ObjectID(idString);
// ----------------------------------------------------------------------------
// should construct with `ObjectID.createFromTime(time)` and should have 0's at the end
oid = ObjectID.createFromTime(time);
// ----------------------------------------------------------------------------
// should construct with `ObjectID.createFromHexString(hexString)`
oid = ObjectID.createFromHexString(hexString);
// ----------------------------------------------------------------------------
// should construct with no arguments
oid = ObjectID();
// ----------------------------------------------------------------------------
// should have an `id` property
oid.id;
// ----------------------------------------------------------------------------
// should have a `str` property
oid.str;
// ----------------------------------------------------------------------------
// should construct with a `time` argument
oid = ObjectID(time);
// ----------------------------------------------------------------------------
// should construct with an `array` argument
oid = ObjectID(array);
// ----------------------------------------------------------------------------
// should construct with a `buffer` argument
oid = ObjectID(buffer);
// ----------------------------------------------------------------------------
// should construct with a `hexString` argument
oid = ObjectID(hexString);
// ----------------------------------------------------------------------------
// should construct with a `idString` argument
oid = ObjectID(idString);
// ----------------------------------------------------------------------------
// should correctly retrieve timestamp
const timestamp:Date = oid.getTimestamp();
// ----------------------------------------------------------------------------
// should validate valid hex strings
let isValid:boolean = ObjectID.isValid(hexString);
// ----------------------------------------------------------------------------
// should validate legit ObjectID objects
isValid = ObjectID.isValid(oid);
// ----------------------------------------------------------------------------
// should invalidate bad strings
// not necessary for typescript
// ----------------------------------------------------------------------------
// should evaluate equality with .equals()
const id1 = new ObjectID();
const id2 = new ObjectID(id1.str);
const equals:boolean = id1.equals(id2);
// ----------------------------------------------------------------------------
// should evaluate equality with via deepEqual
// not necessary for typescript
// ----------------------------------------------------------------------------
// should convert to a hex string for JSON.stringify
// not necessary for typescript
// ----------------------------------------------------------------------------
// should convert to a hex string for ObjectID.toString()
const toStr:string = oid.toString();
// ----------------------------------------------------------------------------
// should throw and error if constructing with an invalid string
// not necessary for typescript