@atproto/lexicon 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -592,20 +592,97 @@ describe('Record validation', () => {
592
592
  })
593
593
 
594
594
  it('Applies grapheme string length constraint', () => {
595
+ // Shorter than two graphemes
596
+ expect(() =>
597
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
598
+ $type: 'com.example.stringLengthGrapheme',
599
+ string: '',
600
+ }),
601
+ ).toThrow('Record/string must not be shorter than 2 graphemes')
602
+ expect(() =>
603
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
604
+ $type: 'com.example.stringLengthGrapheme',
605
+ string: '\u0301\u0301\u0301', // Three combining acute accents
606
+ }),
607
+ ).toThrow('Record/string must not be shorter than 2 graphemes')
608
+ expect(() =>
609
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
610
+ $type: 'com.example.stringLengthGrapheme',
611
+ string: 'a',
612
+ }),
613
+ ).toThrow('Record/string must not be shorter than 2 graphemes')
614
+ expect(() =>
615
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
616
+ $type: 'com.example.stringLengthGrapheme',
617
+ string: 'a\u0301\u0301\u0301\u0301', // 'á́́́' ('a' with four combining acute accents)
618
+ }),
619
+ ).toThrow('Record/string must not be shorter than 2 graphemes')
620
+ expect(() =>
621
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
622
+ $type: 'com.example.stringLengthGrapheme',
623
+ string: '5\uFE0F', // '5️' with emoji presentation
624
+ }),
625
+ ).toThrow('Record/string must not be shorter than 2 graphemes')
626
+ expect(() =>
627
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
628
+ $type: 'com.example.stringLengthGrapheme',
629
+ string: '👨‍👩‍👧‍👧',
630
+ }),
631
+ ).toThrow('Record/string must not be shorter than 2 graphemes')
632
+
633
+ // Two to four graphemes
634
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
635
+ $type: 'com.example.stringLengthGrapheme',
636
+ string: 'ab',
637
+ })
638
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
639
+ $type: 'com.example.stringLengthGrapheme',
640
+ string: 'a\u0301b', // 'áb' with combining accent
641
+ })
642
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
643
+ $type: 'com.example.stringLengthGrapheme',
644
+ string: 'a\u0301b\u0301', // 'áb́'
645
+ })
646
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
647
+ $type: 'com.example.stringLengthGrapheme',
648
+ string: '😀😀',
649
+ })
595
650
  lex.assertValidRecord('com.example.stringLengthGrapheme', {
596
651
  $type: 'com.example.stringLengthGrapheme',
597
652
  string: '12👨‍👩‍👧‍👧',
598
653
  })
654
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
655
+ $type: 'com.example.stringLengthGrapheme',
656
+ string: 'abcd',
657
+ })
658
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
659
+ $type: 'com.example.stringLengthGrapheme',
660
+ string: 'a\u0301b\u0301c\u0301d\u0301', // 'áb́ćd́'
661
+ })
662
+
663
+ // Longer than four graphemes
599
664
  expect(() =>
600
665
  lex.assertValidRecord('com.example.stringLengthGrapheme', {
601
666
  $type: 'com.example.stringLengthGrapheme',
602
- string: '👨‍👩‍👧‍👧',
667
+ string: 'abcde',
603
668
  }),
604
- ).toThrow('Record/string must not be shorter than 2 graphemes')
669
+ ).toThrow('Record/string must not be longer than 4 graphemes')
605
670
  expect(() =>
606
671
  lex.assertValidRecord('com.example.stringLengthGrapheme', {
607
672
  $type: 'com.example.stringLengthGrapheme',
608
- string: '12345',
673
+ string: 'a\u0301b\u0301c\u0301d\u0301e\u0301', // 'áb́ćd́é'
674
+ }),
675
+ ).toThrow('Record/string must not be longer than 4 graphemes')
676
+ expect(() =>
677
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
678
+ $type: 'com.example.stringLengthGrapheme',
679
+ string: '😀😀😀😀😀',
680
+ }),
681
+ ).toThrow('Record/string must not be longer than 4 graphemes')
682
+ expect(() =>
683
+ lex.assertValidRecord('com.example.stringLengthGrapheme', {
684
+ $type: 'com.example.stringLengthGrapheme',
685
+ string: 'ab😀de',
609
686
  }),
610
687
  ).toThrow('Record/string must not be longer than 4 graphemes')
611
688
  })
@@ -0,0 +1 @@
1
+ {"root":["./src/blob-refs.ts","./src/index.ts","./src/lexicons.ts","./src/serialize.ts","./src/types.ts","./src/util.ts","./src/validation.ts","./src/validators/blob.ts","./src/validators/complex.ts","./src/validators/formats.ts","./src/validators/primitives.ts","./src/validators/xrpc.ts"],"version":"5.6.3"}
@@ -0,0 +1 @@
1
+ {"root":["./tests/general.test.ts","./tests/_scaffolds/lexicons.ts"],"version":"5.6.3"}