@@ -2742,6 +2742,94 @@ describe('createDocumentApi', () => {
27422742 ) . not . toThrow ( ) ;
27432743 } ) ;
27442744
2745+ // -- unmergeCells mixed cell/table-scoped locator validation --
2746+
2747+ it ( 'accepts direct cell nodeId for unmergeCells' , ( ) => {
2748+ const api = makeApi ( ) ;
2749+ expect ( ( ) => api . tables . unmergeCells ( { nodeId : 'cell-1' } ) ) . not . toThrow ( ) ;
2750+ } ) ;
2751+
2752+ it ( 'accepts direct cell target for unmergeCells' , ( ) => {
2753+ const api = makeApi ( ) ;
2754+ const target = { kind : 'block' as const , nodeType : 'tableCell' as const , nodeId : 'c1' } ;
2755+ expect ( ( ) => api . tables . unmergeCells ( { target } ) ) . not . toThrow ( ) ;
2756+ } ) ;
2757+
2758+ it ( 'treats explicit null coordinates as absent for direct cell target on unmergeCells' , ( ) => {
2759+ const api = makeApi ( ) ;
2760+ const target = { kind : 'block' as const , nodeType : 'tableCell' as const , nodeId : 'c1' } ;
2761+ expect ( ( ) => api . tables . unmergeCells ( { target, rowIndex : null , columnIndex : null } as any ) ) . not . toThrow ( ) ;
2762+ } ) ;
2763+
2764+ it ( 'accepts table-scoped locator (nodeId + rowIndex + columnIndex) for unmergeCells' , ( ) => {
2765+ const api = makeApi ( ) ;
2766+ expect ( ( ) => api . tables . unmergeCells ( { nodeId : 'table-1' , rowIndex : 0 , columnIndex : 0 } ) ) . not . toThrow ( ) ;
2767+ } ) ;
2768+
2769+ it ( 'accepts table-scoped locator (target + rowIndex + columnIndex) for unmergeCells' , ( ) => {
2770+ const api = makeApi ( ) ;
2771+ const target = { kind : 'block' as const , nodeType : 'table' as const , nodeId : 't1' } ;
2772+ expect ( ( ) => api . tables . unmergeCells ( { target, rowIndex : 0 , columnIndex : 0 } ) ) . not . toThrow ( ) ;
2773+ } ) ;
2774+
2775+ it ( 'treats explicit undefined coordinates as a direct cell call for unmergeCells' , ( ) => {
2776+ const api = makeApi ( ) ;
2777+ // { nodeId, rowIndex: undefined, columnIndex: undefined } must pass validation
2778+ // as a direct-cell call — the keys exist but the values are absent.
2779+ expect ( ( ) =>
2780+ api . tables . unmergeCells ( { nodeId : 'cell-1' , rowIndex : undefined , columnIndex : undefined } as any ) ,
2781+ ) . not . toThrow ( ) ;
2782+ } ) ;
2783+
2784+ it ( 'rejects unmergeCells with only rowIndex (missing columnIndex)' , ( ) => {
2785+ const api = makeApi ( ) ;
2786+ expect ( ( ) => api . tables . unmergeCells ( { nodeId : 'table-1' , rowIndex : 0 } as any ) ) . toThrow (
2787+ / b o t h r o w I n d e x a n d c o l u m n I n d e x / ,
2788+ ) ;
2789+ } ) ;
2790+
2791+ it ( 'rejects unmergeCells with only columnIndex (missing rowIndex)' , ( ) => {
2792+ const api = makeApi ( ) ;
2793+ expect ( ( ) => api . tables . unmergeCells ( { nodeId : 'table-1' , columnIndex : 0 } as any ) ) . toThrow (
2794+ / b o t h r o w I n d e x a n d c o l u m n I n d e x / ,
2795+ ) ;
2796+ } ) ;
2797+
2798+ it ( 'rejects unmergeCells with cell target plus coordinates' , ( ) => {
2799+ const api = makeApi ( ) ;
2800+ const target = { kind : 'block' as const , nodeType : 'tableCell' as const , nodeId : 'c1' } ;
2801+ expect ( ( ) => api . tables . unmergeCells ( { target, rowIndex : 0 , columnIndex : 0 } as any ) ) . toThrow (
2802+ / m u s t n o t b e p r o v i d e d w h e n t a r g e t i s a c e l l n o d e / ,
2803+ ) ;
2804+ } ) ;
2805+
2806+ it ( 'rejects unmergeCells with table target without coordinates' , ( ) => {
2807+ const api = makeApi ( ) ;
2808+ const target = { kind : 'block' as const , nodeType : 'table' as const , nodeId : 't1' } ;
2809+ expect ( ( ) => api . tables . unmergeCells ( { target } as any ) ) . toThrow (
2810+ / r o w I n d e x a n d c o l u m n I n d e x a r e r e q u i r e d w h e n t a r g e t i s a t a b l e / ,
2811+ ) ;
2812+ } ) ;
2813+
2814+ it ( 'rejects unmergeCells with table target and null coordinates' , ( ) => {
2815+ const api = makeApi ( ) ;
2816+ const target = { kind : 'block' as const , nodeType : 'table' as const , nodeId : 't1' } ;
2817+ expect ( ( ) => api . tables . unmergeCells ( { target, rowIndex : null , columnIndex : null } as any ) ) . toThrow (
2818+ / r o w I n d e x a n d c o l u m n I n d e x a r e r e q u i r e d w h e n t a r g e t i s a t a b l e / ,
2819+ ) ;
2820+ } ) ;
2821+
2822+ it ( 'rejects unmergeCells with table target and mixed null coordinates' , ( ) => {
2823+ const api = makeApi ( ) ;
2824+ const target = { kind : 'block' as const , nodeType : 'table' as const , nodeId : 't1' } ;
2825+ expect ( ( ) => api . tables . unmergeCells ( { target, rowIndex : null , columnIndex : 0 } as any ) ) . toThrow (
2826+ / b o t h r o w I n d e x a n d c o l u m n I n d e x / ,
2827+ ) ;
2828+ expect ( ( ) => api . tables . unmergeCells ( { target, rowIndex : 0 , columnIndex : null } as any ) ) . toThrow (
2829+ / b o t h r o w I n d e x a n d c o l u m n I n d e x / ,
2830+ ) ;
2831+ } ) ;
2832+
27452833 // -- create.table locator validation --
27462834
27472835 it ( 'rejects ambiguous create.table at locator (both target + nodeId)' , ( ) => {
0 commit comments