-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: office xml addin telemetry (#11055)
- Loading branch information
Showing
10 changed files
with
159 additions
and
29 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
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
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
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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* @author [email protected] | ||
*/ | ||
|
||
import { Context, Inputs, ok, Platform } from "@microsoft/teamsfx-api"; | ||
import { Context, Inputs, ok, Platform, err, SystemError } from "@microsoft/teamsfx-api"; | ||
import * as chai from "chai"; | ||
import * as childProcess from "child_process"; | ||
import fs from "fs"; | ||
|
@@ -31,6 +31,7 @@ describe("OfficeXMLAddinGenerator", function () { | |
const testFolder = path.resolve("./tmp"); | ||
let context: Context; | ||
let mockedEnvRestore: RestoreFn; | ||
const mockedError = new SystemError("mockedSource", "mockedError", "mockedMessage"); | ||
|
||
beforeEach(async () => { | ||
mockedEnvRestore = mockedEnv( | ||
|
@@ -106,7 +107,7 @@ describe("OfficeXMLAddinGenerator", function () { | |
[QuestionNames.Capabilities]: "word-manifest", | ||
[QuestionNames.AppName]: "office-addin-test", | ||
[QuestionNames.OfficeAddinFolder]: undefined, | ||
[QuestionNames.ProgrammingLanguage]: "typescript", | ||
[QuestionNames.ProgrammingLanguage]: "javascript", | ||
}; | ||
|
||
sinon.stub(Generator, "generateTemplate").resolves(ok(undefined)); | ||
|
@@ -134,6 +135,66 @@ describe("OfficeXMLAddinGenerator", function () { | |
|
||
chai.assert.isTrue(result.isErr()); | ||
}); | ||
|
||
it("should failed when get manifest-only failed", async () => { | ||
const inputs: Inputs = { | ||
platform: Platform.CLI, | ||
projectPath: testFolder, | ||
[QuestionNames.ProjectType]: ProjectTypeOptions.officeXMLAddin().id, | ||
[QuestionNames.OfficeAddinHost]: OfficeAddinHostOptions.word().id, | ||
[QuestionNames.Capabilities]: ["word-manifest"], | ||
[QuestionNames.AppName]: "office-addin-test", | ||
[QuestionNames.OfficeAddinFolder]: undefined, | ||
[QuestionNames.ProgrammingLanguage]: "javascript", | ||
}; | ||
|
||
sinon.stub(Generator, "generateTemplate").onCall(0).resolves(err(mockedError)); | ||
const result = await OfficeXMLAddinGenerator.generate(context, inputs, testFolder); | ||
|
||
chai.assert.isTrue(result.isErr()); | ||
}); | ||
|
||
it("should failed when get readme failed", async () => { | ||
const inputs: Inputs = { | ||
platform: Platform.CLI, | ||
projectPath: testFolder, | ||
[QuestionNames.ProjectType]: ProjectTypeOptions.officeXMLAddin().id, | ||
[QuestionNames.OfficeAddinHost]: OfficeAddinHostOptions.word().id, | ||
[QuestionNames.Capabilities]: ["word-manifest"], | ||
[QuestionNames.AppName]: "office-addin-test", | ||
[QuestionNames.OfficeAddinFolder]: undefined, | ||
[QuestionNames.ProgrammingLanguage]: "javascript", | ||
}; | ||
|
||
const generatorStub = sinon.stub(Generator, "generateTemplate"); | ||
generatorStub.onCall(0).resolves(ok(undefined)); | ||
generatorStub.onCall(1).resolves(err(mockedError)); | ||
const result = await OfficeXMLAddinGenerator.generate(context, inputs, testFolder); | ||
|
||
chai.assert.isTrue(result.isErr()); | ||
}); | ||
|
||
it("should failed when gen yml failed", async () => { | ||
const inputs: Inputs = { | ||
platform: Platform.CLI, | ||
projectPath: testFolder, | ||
[QuestionNames.ProjectType]: ProjectTypeOptions.officeXMLAddin().id, | ||
[QuestionNames.OfficeAddinHost]: OfficeAddinHostOptions.word().id, | ||
[QuestionNames.Capabilities]: ["word-manifest"], | ||
[QuestionNames.AppName]: "office-addin-test", | ||
[QuestionNames.OfficeAddinFolder]: undefined, | ||
[QuestionNames.ProgrammingLanguage]: "javascript", | ||
}; | ||
|
||
const generatorStub = sinon.stub(Generator, "generateTemplate"); | ||
generatorStub.onCall(0).resolves(ok(undefined)); | ||
generatorStub.onCall(1).resolves(ok(undefined)); | ||
generatorStub.onCall(2).resolves(err(mockedError)); | ||
sinon.stub(OfficeAddinManifest, "modifyManifestFile").resolves({}); | ||
const result = await OfficeXMLAddinGenerator.generate(context, inputs, testFolder); | ||
|
||
chai.assert.isTrue(result.isErr()); | ||
}); | ||
}); | ||
|
||
describe("getOfficeAddinTemplateConfig", () => { | ||
|
Oops, something went wrong.