Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createTestInjector(devices?: IAttachedDevices): IInjector {
const customEventEmitter = new CustomDeviceEmitter(devices);
const testInjector = new Yok();
testInjector.register("injector", testInjector);
testInjector.register("nsCloudDeviceEmulator", {
get deviceEmitter() {
return customEventEmitter;
}
});
testInjector.register("nsCloudServerEmulatorsService", { /* empty */ });
testInjector.register("mobileHelper", {
normalizePlatformName: (platform: string) => platform.toLowerCase()
});
return testInjector;
}
function createTestInjector(): IInjector {
const testInjector = new Yok();
testInjector.register("nsCloudServerRequestService", {
call: async () => emulatorCredentials
});
testInjector.register("fs", {
exists: () => true,
readJson: () => ({}),
writeJson: () => { /* empty */ }
});
testInjector.register("nsCloudUploadService", {
uploadToS3: async (url: string) => url
});
testInjector.register("nsCloudDeviceEmulator", { /* empty */ });
testInjector.register("options", {
profileDir: "test"
});
testInjector.register("nsCloudEulaService", {
it("returns the real version of the package", async () => {
const testInjector = new Yok();
testInjector.register("fs", FileSystem);
let message: string = null;
const loggerInfo = (msg: string) => {
message = msg;
};
testInjector.register("logger", {
info: loggerInfo
});
testInjector.register("nsCloudPackageInfoService", PackageInfoService);
testInjector.registerCommand("command", CloudLibVersion);
await testInjector.resolveCommand("command").execute([]);
const realVersion = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json")).toString()).version;
const createTestInjector = (): IInjector => {
const testInjector = new Yok();
testInjector.register("nsCloudErrorsService", {
fail: (message: string, ...args: any[]): never => { throw new Error(message); }
});
testInjector.register("logger", {
printMarkdown: (...args: any[]): void => undefined,
trace: (formatStr?: any, ...args: any[]): void => undefined,
info: (formatStr?: any, ...args: any[]): void => undefined,
});
testInjector.register("nsCloudEulaService", {
acceptEula: async (): Promise => undefined,
getEulaDataWithCache: async (): Promise => ({ url: EulaConstants.eulaUrl, shouldAcceptEula: true })
});
testInjector.register("prompter", {
const createTestInjector = (cloudConfigurationData?: ICloudConfigurationData): IInjector => {
const testInjector = new Yok();
testInjector.register("logger", {
trace: (formatStr?: any, ...args: any[]): void => (undefined)
});
testInjector.register("httpClient", {});
testInjector.register("nsCloudConfigurationService", {
getCloudConfigurationData: () => cloudConfigurationData
});
testInjector.register("nsCloudPolyfillService", PolyfillService);
testInjector.register("projectDataService", {});
return testInjector;
};
const createTestInjector = (): IInjector => {
const testInjector = new Yok();
testInjector.register("logger", {});
testInjector.register("nsCloudCommunicationChannelFactory", CommunicationChannelFactory);
testInjector.register("nsCloudWebSocketFactory", {
create: (): any => null
});
testInjector.register("injector", testInjector);
return testInjector;
};
beforeEach(() => {