All files / json-hash/__tests__ assertStructHash.ts

100% Statements 15/15
100% Branches 0/0
100% Functions 2/2
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 203x 3x 3x     491x   3x 491x 491x 491x 491x     491x 491x 491x 491x    
import {structHash as structHash_} from '../structHash';
import {structHashCrdt} from '../structHashCrdt';
import {Model} from '../../json-crdt';
 
// biome-ignore lint: \x00 character
const isASCII = (str: string) => /^[\x00-\x7F]*$/.test(str);
 
export const assertStructHash = (json: unknown): string => {
  const model = Model.create();
  model.api.root(json);
  const hash1 = structHashCrdt(model.root);
  const hash2 = structHash_(json);
  // console.log(hash1);
  // console.log(hash2);
  expect(hash1).toBe(hash2);
  expect(hash2.includes('\n')).toBe(false);
  expect(isASCII(hash2)).toBe(true);
  return hash2;
};