@contractkit/plugin-bruno 1.1.0 → 1.2.0

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.
@@ -671,6 +671,48 @@ describe('generateOpenCollection', () => {
671
671
  expect(env!.content).toContain('- name: token');
672
672
  });
673
673
 
674
+ describe('alphabetical ordering', () => {
675
+ function seqOf(content: string): number | undefined {
676
+ const match = content.match(/seq:\s*(\d+)/);
677
+ return match ? parseInt(match[1]!, 10) : undefined;
678
+ }
679
+
680
+ it('orders top-level folders alphabetically by area', () => {
681
+ const usersRoot = opRoot([opRoute('/users', [opOperation('get')])], 'users.op', { area: 'users' });
682
+ const authRoot = opRoot([opRoute('/auth', [opOperation('post')])], 'auth.op', { area: 'auth' });
683
+ const paymentsRoot = opRoot([opRoute('/payments', [opOperation('get')])], 'payments.op', { area: 'payments' });
684
+ // Pass in a non-alphabetical input order to prove the sort is doing the work.
685
+ const files = generateOpenCollection([usersRoot, authRoot, paymentsRoot], { collectionName: 'API' });
686
+
687
+ const auth = files.find(f => f.relativePath === 'auth/folder.yml');
688
+ const payments = files.find(f => f.relativePath === 'payments/folder.yml');
689
+ const users = files.find(f => f.relativePath === 'users/folder.yml');
690
+ expect(seqOf(auth!.content)).toBe(1);
691
+ expect(seqOf(payments!.content)).toBe(2);
692
+ expect(seqOf(users!.content)).toBe(3);
693
+ });
694
+
695
+ it('orders requests within a folder alphabetically by request name', () => {
696
+ const root = opRoot(
697
+ [
698
+ opRoute('/zebras', [opOperation('get', { name: 'Zebra list' })]),
699
+ opRoute('/aardvarks', [opOperation('get', { name: 'Aardvark list' })]),
700
+ opRoute('/mammals', [opOperation('get', { name: 'Mammal list' })]),
701
+ ],
702
+ 'zoo.op',
703
+ { area: 'zoo' },
704
+ );
705
+ const files = generateOpenCollection([root], { collectionName: 'API' });
706
+
707
+ const aardvark = files.find(f => f.relativePath === 'zoo/aardvark-list.yml');
708
+ const mammal = files.find(f => f.relativePath === 'zoo/mammal-list.yml');
709
+ const zebra = files.find(f => f.relativePath === 'zoo/zebra-list.yml');
710
+ expect(seqOf(aardvark!.content)).toBe(1);
711
+ expect(seqOf(mammal!.content)).toBe(2);
712
+ expect(seqOf(zebra!.content)).toBe(3);
713
+ });
714
+ });
715
+
674
716
  describe('environments config', () => {
675
717
  const root = opRoot([opRoute('/users', [opOperation('get')])], 'users.op');
676
718