-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e1ec77
commit 1a213fa
Showing
4 changed files
with
144 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tools/apiview/emitters/cadl-apiview/test/apiview-options.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Diagnostic, logDiagnostics, resolvePath } from "@cadl-lang/compiler"; | ||
import { expectDiagnosticEmpty } from "@cadl-lang/compiler/testing"; | ||
import { strictEqual } from "assert"; | ||
import { apiViewFor, apiViewText, compare } from "./test-host.js"; | ||
|
||
describe("apiview-options: tests", () => { | ||
|
||
it("omits namespaces that aren't proper subnamespaces", async () => { | ||
const input = ` | ||
@Cadl.service( { title: "Test", version: "1" } ) | ||
namespace Azure.Test { | ||
model Foo {}; | ||
} | ||
namespace Azure.Test.Sub { | ||
model SubFoo {}; | ||
}; | ||
namespace Azure.TestBad { | ||
model BadFoo {}; | ||
}; | ||
`; | ||
const expect = ` | ||
namespace Azure.Test { | ||
model Foo {} | ||
} | ||
namespace Azure.Test.Sub { | ||
model SubFoo {} | ||
} | ||
` | ||
const apiview = await apiViewFor(input, {}); | ||
const actual = apiViewText(apiview); | ||
compare(expect, actual, 9); | ||
}); | ||
|
||
it("outputs the global namespace when --include-global-namespace is set", async () => { | ||
const input = ` | ||
model SomeGlobal {}; | ||
@Cadl.service( { title: "Test", version: "1" } ) | ||
namespace Azure.Test { | ||
model Foo {}; | ||
} | ||
`; | ||
const expect = ` | ||
model SomeGlobal {}; | ||
namespace Azure.Test { | ||
model Foo {} | ||
} | ||
` | ||
const apiview = await apiViewFor(input, { | ||
"include-global-namespace": true | ||
}); | ||
const actual = apiViewText(apiview); | ||
compare(expect, actual, 9); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters