Skip to content

Commit

Permalink
suite fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWeatherford committed Sep 2, 2020
1 parent fd36c9a commit 5e78fe7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
15 changes: 12 additions & 3 deletions test/TemplatePositionContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ suite("TemplatePositionContext", () => {
test("with documentLineIndex equal to document line count", () => {
let dt = new DeploymentTemplateDoc("{}", fakeId);
assert.deepStrictEqual(1, dt.lineCount);
assert.throws(() => { TemplatePositionContext.fromDocumentLineAndColumnIndexes(dt, 1, 0, undefined); });
let pc = TemplatePositionContext.fromDocumentLineAndColumnIndexes(dt, 1, 0, undefined);
assert.strictEqual(0, pc.documentLineIndex);
assert.strictEqual(0, pc.documentColumnIndex);
assert.strictEqual(0, pc.documentCharacterIndex);
});

test("with undefined documentColumnIndex", () => {
Expand All @@ -105,7 +108,10 @@ suite("TemplatePositionContext", () => {

test("with documentColumnIndex greater than line length", () => {
let dt = new DeploymentTemplateDoc("{}", fakeId);
assert.throws(() => { TemplatePositionContext.fromDocumentLineAndColumnIndexes(dt, 0, 3, undefined); });
let pc = TemplatePositionContext.fromDocumentLineAndColumnIndexes(dt, 0, 3, undefined);
assert.strictEqual(0, pc.documentLineIndex);
assert.strictEqual(2, pc.documentColumnIndex);
assert.strictEqual(2, pc.documentCharacterIndex);
});

test("with valid arguments", () => {
Expand Down Expand Up @@ -149,7 +155,10 @@ suite("TemplatePositionContext", () => {

test("with documentCharacterIndex greater than the maximum character index", () => {
let dt = new DeploymentTemplateDoc("{}", fakeId);
assert.throws(() => { TemplatePositionContext.fromDocumentCharacterIndex(dt, 3, undefined); });
let pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, 3, undefined);
assert.strictEqual(0, pc.documentLineIndex);
assert.strictEqual(2, pc.documentColumnIndex);
assert.strictEqual(2, pc.documentCharacterIndex);
});

test("with valid arguments", () => {
Expand Down
44 changes: 30 additions & 14 deletions test/dependsOn.completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ suite("dependsOn completions", () => {

suite("detail", () => {
createDependsOnCompletionsTest(
"detailMatchesFullTypeName",
"detailMatchesTypeNameMinusSegment",
{
template: {
resources: [
Expand All @@ -93,16 +93,34 @@ suite("dependsOn completions", () => {
]
},
{
type: "microsoft.abc/def",
type: "Microsoft.abc/def",
name: "name1a"
},
{
type: "microsoft.123/456/789",
name: "name1b"
},
{
type: "singlesegment",
name: "name1c"
}
]
},
expected: [
{
"label": "'name1a'",
"insertText": `"[resourceId('microsoft.abc/def', 'name1a')]"`,
"detail": "microsoft.abc/def"
"insertText": `"[resourceId('Microsoft.abc/def', 'name1a')]"`,
"detail": "def"
},
{
"label": "'name1b'",
"insertText": `"[resourceId('microsoft.123/456/789', 'name1b')]"`,
"detail": "456/789"
},
{
"label": "'name1c'",
"insertText": `"[resourceId('singlesegment', 'name1c')]"`,
"detail": "singlesegment"
}
]
});
Expand Down Expand Up @@ -131,11 +149,10 @@ suite("dependsOn completions", () => {
"documention": <any>{
value:
// tslint:disable-next-line: prefer-template
`"[resourceId('microsoft.abc/def', 'name1a')]"\n` +
'\n' +
'Reference to resource\n' +
"- **Name**: *'name1a'*\n" +
"- **Type**: *'microsoft.abc/def'*"
"Inserts this resourceId reference:\n" +
"```arm-template\n" +
"\"[resourceId('microsoft.abc/def', 'name1a')]\"\n" +
"```\n<br/>"
}
}
]
Expand Down Expand Up @@ -168,11 +185,10 @@ suite("dependsOn completions", () => {
"documention": <any>{
value:
// tslint:disable-next-line: prefer-template
`Inserts this resourceId reference:\n` +
"```arm-template\n" +
`"[resourceId('microsoft.abc/def', 'name1a')]"\n` +
'\n' +
'Reference to resource\n' +
"- **Name**: *'name1a'*\n" +
"- **Type**: *'microsoft.abc/def'*"
"```\n<br/>"
}
}
]
Expand Down Expand Up @@ -668,7 +684,7 @@ suite("dependsOn completions", () => {
expected: [
{
label: "variables('sqlServer')",
detail: "Microsoft.Sql/servers",
detail: "servers",
insertText: `"[resourceId('Microsoft.Sql/servers', variables('sqlServer'))]"`
}
]
Expand Down

0 comments on commit 5e78fe7

Please sign in to comment.