@@ -64,6 +64,7 @@ describe("normalizeAndValidateConfig()", () => {
64
64
site : undefined ,
65
65
text_blobs : undefined ,
66
66
browser : undefined ,
67
+ ai : undefined ,
67
68
triggers : {
68
69
crons : [ ] ,
69
70
} ,
@@ -1620,6 +1621,64 @@ describe("normalizeAndValidateConfig()", () => {
1620
1621
} ) ;
1621
1622
} ) ;
1622
1623
1624
+ describe ( "[ai]" , ( ) => {
1625
+ it ( "should error if ai is an array" , ( ) => {
1626
+ const { diagnostics } = normalizeAndValidateConfig (
1627
+ { ai : [ ] } as unknown as RawConfig ,
1628
+ undefined ,
1629
+ { env : undefined }
1630
+ ) ;
1631
+
1632
+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
1633
+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
1634
+ "Processing wrangler configuration:
1635
+ - The field \\"ai\\" should be an object but got []."
1636
+ ` ) ;
1637
+ } ) ;
1638
+
1639
+ it ( "should error if ai is a string" , ( ) => {
1640
+ const { diagnostics } = normalizeAndValidateConfig (
1641
+ { ai : "BAD" } as unknown as RawConfig ,
1642
+ undefined ,
1643
+ { env : undefined }
1644
+ ) ;
1645
+
1646
+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
1647
+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
1648
+ "Processing wrangler configuration:
1649
+ - The field \\"ai\\" should be an object but got \\"BAD\\"."
1650
+ ` ) ;
1651
+ } ) ;
1652
+
1653
+ it ( "should error if ai is a number" , ( ) => {
1654
+ const { diagnostics } = normalizeAndValidateConfig (
1655
+ { ai : 999 } as unknown as RawConfig ,
1656
+ undefined ,
1657
+ { env : undefined }
1658
+ ) ;
1659
+
1660
+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
1661
+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
1662
+ "Processing wrangler configuration:
1663
+ - The field \\"ai\\" should be an object but got 999."
1664
+ ` ) ;
1665
+ } ) ;
1666
+
1667
+ it ( "should error if ai is null" , ( ) => {
1668
+ const { diagnostics } = normalizeAndValidateConfig (
1669
+ { ai : null } as unknown as RawConfig ,
1670
+ undefined ,
1671
+ { env : undefined }
1672
+ ) ;
1673
+
1674
+ expect ( diagnostics . hasWarnings ( ) ) . toBe ( false ) ;
1675
+ expect ( diagnostics . renderErrors ( ) ) . toMatchInlineSnapshot ( `
1676
+ "Processing wrangler configuration:
1677
+ - The field \\"ai\\" should be an object but got null."
1678
+ ` ) ;
1679
+ } ) ;
1680
+ } ) ;
1681
+
1623
1682
describe ( "[kv_namespaces]" , ( ) => {
1624
1683
it ( "should error if kv_namespaces is an object" , ( ) => {
1625
1684
const { diagnostics } = normalizeAndValidateConfig (
0 commit comments