type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
TypeAliasDeclaration |
export type TGetPlotsBroadCast = {
plots: Plot[];
failed_to_open_filenames: string[];
not_found_filenames: string[];
}; | 1Megu/chia-agent | src/api/ws/harvester/index.ts | TypeScript |
TypeAliasDeclaration | // Whole commands for the service
export type chia_harvester_commands = get_plots_command; | 1Megu/chia-agent | src/api/ws/harvester/index.ts | TypeScript |
TypeAliasDeclaration |
export type TChiaHarvesterBroadcast = TGetPlotsBroadCast; | 1Megu/chia-agent | src/api/ws/harvester/index.ts | TypeScript |
ArrowFunction |
({ onSelectChange }) => {
const { selectedAccount, extensionStatus, setSelectedAccount, deactivate } =
useContext(ParachainContext);
const { accounts } = usePicassoProvider();
const theme = useTheme();
const dispatch = useAppDispatch();
const handleConfirm = () => {
// dispatch(setSelectedAccount(selected));
dispatch(closePolkadotModal());
};
const handleDisconnect = () => {
if (deactivate) deactivate();
};
let currAccount = accounts.find((v, i) => i === selectedAccount);
currAccount = !!currAccount ? currAccount : { name: "", address: "" };
return (
<Box
sx={{
marginTop: theme.spacing(5),
display: "flex",
flexDirection: "column",
gap: 4,
width: "100%",
}} | ComposableFi/composable | frontend/ui-picasso/app/components/Organisms/Wallet/PolkadotAccountForm.tsx | TypeScript |
ArrowFunction |
() => {
// dispatch(setSelectedAccount(selected));
dispatch(closePolkadotModal());
} | ComposableFi/composable | frontend/ui-picasso/app/components/Organisms/Wallet/PolkadotAccountForm.tsx | TypeScript |
ArrowFunction |
() => {
if (deactivate) deactivate();
} | ComposableFi/composable | frontend/ui-picasso/app/components/Organisms/Wallet/PolkadotAccountForm.tsx | TypeScript |
ArrowFunction |
(v, i) => i === selectedAccount | ComposableFi/composable | frontend/ui-picasso/app/components/Organisms/Wallet/PolkadotAccountForm.tsx | TypeScript |
ArrowFunction |
(account, index) => (
<Button
key={index} | ComposableFi/composable | frontend/ui-picasso/app/components/Organisms/Wallet/PolkadotAccountForm.tsx | TypeScript |
MethodDeclaration | // setSelected(account);
if (setSelectedAccount) {
setSelectedAccount(index);
} | ComposableFi/composable | frontend/ui-picasso/app/components/Organisms/Wallet/PolkadotAccountForm.tsx | TypeScript |
FunctionDeclaration |
export default function PhoneMaskedInput(props: TextMaskCustomProps) {
const { inputRef, ...other } = props;
return (
<MaskedInput
{...other}
ref={(ref: any) => {
inputRef(ref ? ref.inputElement : null);
}} | KarelChanivecky/COMP-2800-TEAM-DTC-01-Q-Up | q_up-client/src/components/PhoneMaskedInput.tsx | TypeScript |
FunctionDeclaration |
export function unMaskPhone(phoneNumber:string) {
return phoneNumber.slice(1, 4) + phoneNumber.slice(6, 9) + phoneNumber.slice(10)
} | KarelChanivecky/COMP-2800-TEAM-DTC-01-Q-Up | q_up-client/src/components/PhoneMaskedInput.tsx | TypeScript |
InterfaceDeclaration |
interface TextMaskCustomProps {
inputRef: (ref: HTMLInputElement | null) => void;
} | KarelChanivecky/COMP-2800-TEAM-DTC-01-Q-Up | q_up-client/src/components/PhoneMaskedInput.tsx | TypeScript |
ArrowFunction |
() => {
beforeEach(() => {
// reset mock client
ec2ClientMock.reset();
});
it('should return nat gateways associated with passed vpc', async () => {
ec2ClientMock.on(DescribeNatGatewaysCommand).resolves({
NatGateways: [
{
NatGatewayId: 'natgw1',
State: 'associated',
},
],
});
const gw: NatGateway[] = await getNatGateways(
'us-east-1',
'default',
'vpc-12345678'
);
expect(gw.length).toBe(1);
expect(gw[0].id).toBe('natgw1');
});
it('should not return nat gateways not associated with passed vpc', async () => {
ec2ClientMock.on(DescribeNatGatewaysCommand).resolves({
NatGateways: [],
});
const gw: NatGateway[] = await getNatGateways(
'us-east-1',
'default',
'vpc-11111111'
);
expect(gw.length).toBe(0);
});
it('should not return nat gateways when nat gateway fetch fails', async () => {
ec2ClientMock.on(DescribeNatGatewaysCommand).rejects({
message: 'failed',
});
await expect(
getNatGateways('us-east-1', 'default', 'vpc-11111111')
).rejects.toThrow('Error getting the NAT gateways of vpc vpc-11111111');
});
} | RishikeshDarandale/vpc-describe | src/tests/network/NatGateway.test.ts | TypeScript |
ArrowFunction |
() => {
// reset mock client
ec2ClientMock.reset();
} | RishikeshDarandale/vpc-describe | src/tests/network/NatGateway.test.ts | TypeScript |
ArrowFunction |
async () => {
ec2ClientMock.on(DescribeNatGatewaysCommand).resolves({
NatGateways: [
{
NatGatewayId: 'natgw1',
State: 'associated',
},
],
});
const gw: NatGateway[] = await getNatGateways(
'us-east-1',
'default',
'vpc-12345678'
);
expect(gw.length).toBe(1);
expect(gw[0].id).toBe('natgw1');
} | RishikeshDarandale/vpc-describe | src/tests/network/NatGateway.test.ts | TypeScript |
ArrowFunction |
async () => {
ec2ClientMock.on(DescribeNatGatewaysCommand).resolves({
NatGateways: [],
});
const gw: NatGateway[] = await getNatGateways(
'us-east-1',
'default',
'vpc-11111111'
);
expect(gw.length).toBe(0);
} | RishikeshDarandale/vpc-describe | src/tests/network/NatGateway.test.ts | TypeScript |
ArrowFunction |
async () => {
ec2ClientMock.on(DescribeNatGatewaysCommand).rejects({
message: 'failed',
});
await expect(
getNatGateways('us-east-1', 'default', 'vpc-11111111')
).rejects.toThrow('Error getting the NAT gateways of vpc vpc-11111111');
} | RishikeshDarandale/vpc-describe | src/tests/network/NatGateway.test.ts | TypeScript |
ArrowFunction |
data => {
console.log(data)
this.employee = data;
} | parmarakhil/schoolManagement | FE/schoolmanagementFE/src/app/update-employee/update-employee.component.ts | TypeScript |
ArrowFunction |
data => {
console.log(data);
this.employee = new Employee();
this.gotoList();
} | parmarakhil/schoolManagement | FE/schoolmanagementFE/src/app/update-employee/update-employee.component.ts | TypeScript |
ClassDeclaration |
@Component({
selector: 'app-update-employee',
templateUrl: './update-employee.component.html',
styleUrls: ['./update-employee.component.css']
})
export class UpdateEmployeeComponent implements OnInit {
id: number;
employee: Employee;
constructor(private route: ActivatedRoute,private router: Router,
private employeeService: EmployeeService) { }
ngOnInit() {
this.employee = new Employee();
this.id = this.route.snapshot.params['id'];
this.employeeService.getEmployee(this.id)
.subscribe(data => {
console.log(data)
this.employee = data;
}, error => console.log(error));
}
updateEmployee() {
this.employeeService.updateEmployee(this.id, this.employee)
.subscribe(data => {
console.log(data);
this.employee = new Employee();
this.gotoList();
}, error => console.log(error));
}
onSubmit() {
this.updateEmployee();
}
gotoList() {
this.router.navigate(['/employees']);
}
} | parmarakhil/schoolManagement | FE/schoolmanagementFE/src/app/update-employee/update-employee.component.ts | TypeScript |
MethodDeclaration |
ngOnInit() {
this.employee = new Employee();
this.id = this.route.snapshot.params['id'];
this.employeeService.getEmployee(this.id)
.subscribe(data => {
console.log(data)
this.employee = data;
}, error => console.log(error));
} | parmarakhil/schoolManagement | FE/schoolmanagementFE/src/app/update-employee/update-employee.component.ts | TypeScript |
MethodDeclaration |
updateEmployee() {
this.employeeService.updateEmployee(this.id, this.employee)
.subscribe(data => {
console.log(data);
this.employee = new Employee();
this.gotoList();
}, error => console.log(error));
} | parmarakhil/schoolManagement | FE/schoolmanagementFE/src/app/update-employee/update-employee.component.ts | TypeScript |
MethodDeclaration |
onSubmit() {
this.updateEmployee();
} | parmarakhil/schoolManagement | FE/schoolmanagementFE/src/app/update-employee/update-employee.component.ts | TypeScript |
MethodDeclaration |
gotoList() {
this.router.navigate(['/employees']);
} | parmarakhil/schoolManagement | FE/schoolmanagementFE/src/app/update-employee/update-employee.component.ts | TypeScript |
ArrowFunction |
() => {
it("allows comparisons of objects", () => {
const example = { 1: 1, 2: 2 };
const hashedObject = hashValue(example);
expect(hashValue(example)).toBe(hashedObject);
});
it("allows comparisons of arrays", () => {
const example = [1, 2];
const hashedArray = hashValue(example);
expect(hashValue(example)).toBe(hashedArray);
});
it("allows comparisons of arrays of objects", () => {
const example = [
{ 1: 1, 2: 2 },
{ 3: 3, 4: 4 },
];
const hashedValue = hashValue(example);
expect(hashValue(example)).toBe(hashedValue);
});
} | Barbacoa08/barbie-meals | src/utils/hash-value/hash-value.test.ts | TypeScript |
ArrowFunction |
() => {
const example = { 1: 1, 2: 2 };
const hashedObject = hashValue(example);
expect(hashValue(example)).toBe(hashedObject);
} | Barbacoa08/barbie-meals | src/utils/hash-value/hash-value.test.ts | TypeScript |
ArrowFunction |
() => {
const example = [1, 2];
const hashedArray = hashValue(example);
expect(hashValue(example)).toBe(hashedArray);
} | Barbacoa08/barbie-meals | src/utils/hash-value/hash-value.test.ts | TypeScript |
ArrowFunction |
() => {
const example = [
{ 1: 1, 2: 2 },
{ 3: 3, 4: 4 },
];
const hashedValue = hashValue(example);
expect(hashValue(example)).toBe(hashedValue);
} | Barbacoa08/barbie-meals | src/utils/hash-value/hash-value.test.ts | TypeScript |
ArrowFunction |
(
req: Request,
payload: ObjectShape
) => {
return Yup.object().shape(payload).validate(req.body, { abortEarly: false })
} | HaikalLuzain/todo-list | src/utils/validation.ts | TypeScript |
ArrowFunction |
(error: any, res: Response) => {
const errors: any = {}
error.inner.forEach((item: any) => {
errors[item.path] = item.message
})
return res.status(422).json({
error: {
statusCode: StatusCodes.UNPROCESSABLE_ENTITY,
message: ReasonPhrases.UNPROCESSABLE_ENTITY,
errors,
},
})
// if (Object.keys(errors).length > 0) {
// return false
// }
// return true
} | HaikalLuzain/todo-list | src/utils/validation.ts | TypeScript |
ArrowFunction |
(item: any) => {
errors[item.path] = item.message
} | HaikalLuzain/todo-list | src/utils/validation.ts | TypeScript |
FunctionDeclaration | // AoT requires an exported function for factories
export function createTranslateLoader(http: HttpClient) {
// for development
// return new TranslateHttpLoader(http, '/start-angular/SB-Admin-BS4-Angular-5/master/dist/assets/i18n/', '.json');
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
} | raulluque/MercadoLibreAngular5 | src/app/app.module.ts | TypeScript |
ClassDeclaration |
@NgModule({
imports: [
CommonModule,
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient]
}
}),
AngularFireAuthModule,
AngularFirestoreModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AppRoutingModule
],
declarations: [AppComponent],
providers: [AuthGuard,MeliService,AngularFireDatabase],
bootstrap: [AppComponent]
})
export class AppModule {} | raulluque/MercadoLibreAngular5 | src/app/app.module.ts | TypeScript |
ClassDeclaration |
export class Shader extends GLShader {
constructor(gl: WebGL2RenderingContext, vertexSrc?: string, fragmentSrc?: string) {
super(gl, vertexSrc, fragmentSrc);
}
apply(): void {}
applyMaterial(material: Material): void {}
applyMesh(mesh: Mesh): void {}
applyNode(node: SceneNode): void {}
applyScene(scene: Scene): void {}
} | Xan0C/curbl-gltf-viewer | src/scene/shader.ts | TypeScript |
MethodDeclaration |
apply(): void {} | Xan0C/curbl-gltf-viewer | src/scene/shader.ts | TypeScript |
MethodDeclaration |
applyMaterial(material: Material): void {} | Xan0C/curbl-gltf-viewer | src/scene/shader.ts | TypeScript |
MethodDeclaration |
applyMesh(mesh: Mesh): void {} | Xan0C/curbl-gltf-viewer | src/scene/shader.ts | TypeScript |
MethodDeclaration |
applyNode(node: SceneNode): void {} | Xan0C/curbl-gltf-viewer | src/scene/shader.ts | TypeScript |
MethodDeclaration |
applyScene(scene: Scene): void {} | Xan0C/curbl-gltf-viewer | src/scene/shader.ts | TypeScript |
ClassDeclaration |
export class NewsDTO {
constructor(
public information: string,
public dateTime: Date,
public culturalSiteName: string,
public images: Image[],
public id: number
) {}
} | ksenija10/KTSNVT_2020_T13 | serbioneer-front/src/app/model/news.model.ts | TypeScript |
FunctionDeclaration |
async function runTestApp (name: string, ...args: any[]) {
const appPath = path.join(fixturesPath, 'api', name);
const electronPath = process.execPath;
const appProcess = cp.spawn(electronPath, [appPath, ...args]);
let output = '';
appProcess.stdout.on('data', (data) => { output += data; });
await emittedOnce(appProcess.stdout, 'end');
return JSON.parse(output);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('does not expose internal modules to require', () => {
expect(() => {
require('clipboard');
}).to.throw(/Cannot find module 'clipboard'/);
});
describe('require("electron")', () => {
it('always returns the internal electron module', () => {
require('electron');
});
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(() => {
require('clipboard');
}).to.throw(/Cannot find module 'clipboard'/);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
require('clipboard');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('always returns the internal electron module', () => {
require('electron');
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
require('electron');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
(done) => {
const options = {
key: fs.readFileSync(path.join(certPath, 'server.key')),
cert: fs.readFileSync(path.join(certPath, 'server.pem')),
ca: [
fs.readFileSync(path.join(certPath, 'rootCA.pem')),
fs.readFileSync(path.join(certPath, 'intermediateCA.pem'))
],
requestCert: true,
rejectUnauthorized: false
};
server = https.createServer(options, (req, res) => {
if ((req as any).client.authorized) {
res.writeHead(200);
res.end('<title>authorized</title>');
} else {
res.writeHead(401);
res.end('<title>denied</title>');
}
});
server.listen(0, '127.0.0.1', () => {
const port = (server.address() as net.AddressInfo).port;
secureUrl = `https://127.0.0.1:${port}`;
done();
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
(req, res) => {
if ((req as any).client.authorized) {
res.writeHead(200);
res.end('<title>authorized</title>');
} else {
res.writeHead(401);
res.end('<title>denied</title>');
}
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
const port = (server.address() as net.AddressInfo).port;
secureUrl = `https://127.0.0.1:${port}`;
done();
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
done => {
server.close(() => done());
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => done() | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('returns the version field of package.json', () => {
expect(app.getVersion()).to.equal('0.1.0');
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.getVersion()).to.equal('0.1.0');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('overrides the version', () => {
expect(app.getVersion()).to.equal('0.1.0');
app.setVersion('test-version');
expect(app.getVersion()).to.equal('test-version');
app.setVersion('0.1.0');
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.getVersion()).to.equal('0.1.0');
app.setVersion('test-version');
expect(app.getVersion()).to.equal('test-version');
app.setVersion('0.1.0');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('with properties', () => {
it('returns the name field of package.json', () => {
expect(app.name).to.equal('Electron Test Main');
});
it('overrides the name', () => {
expect(app.name).to.equal('Electron Test Main');
app.name = 'test-name';
expect(app.name).to.equal('test-name');
app.name = 'Electron Test Main';
});
});
it('with functions', () => {
it('returns the name field of package.json', () => {
expect(app.getName()).to.equal('Electron Test Main');
});
it('overrides the name', () => {
expect(app.getName()).to.equal('Electron Test Main');
app.setName('test-name');
expect(app.getName()).to.equal('test-name');
app.setName('Electron Test Main');
});
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('returns the name field of package.json', () => {
expect(app.name).to.equal('Electron Test Main');
});
it('overrides the name', () => {
expect(app.name).to.equal('Electron Test Main');
app.name = 'test-name';
expect(app.name).to.equal('test-name');
app.name = 'Electron Test Main';
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.name).to.equal('Electron Test Main');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.name).to.equal('Electron Test Main');
app.name = 'test-name';
expect(app.name).to.equal('test-name');
app.name = 'Electron Test Main';
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('returns the name field of package.json', () => {
expect(app.getName()).to.equal('Electron Test Main');
});
it('overrides the name', () => {
expect(app.getName()).to.equal('Electron Test Main');
app.setName('test-name');
expect(app.getName()).to.equal('test-name');
app.setName('Electron Test Main');
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.getName()).to.equal('Electron Test Main');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.getName()).to.equal('Electron Test Main');
app.setName('test-name');
expect(app.getName()).to.equal('test-name');
app.setName('Electron Test Main');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('should not be empty', () => {
expect(app.getLocale()).to.not.equal('');
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.getLocale()).to.not.equal('');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('should be empty or have length of two', () => {
let expectedLength = 2;
if (process.platform === 'linux') {
// Linux CI machines have no locale.
expectedLength = 0;
}
expect(app.getLocaleCountryCode()).to.be.a('string').and.have.lengthOf(expectedLength);
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
let expectedLength = 2;
if (process.platform === 'linux') {
// Linux CI machines have no locale.
expectedLength = 0;
}
expect(app.getLocaleCountryCode()).to.be.a('string').and.have.lengthOf(expectedLength);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('should be false durings tests', () => {
expect(app.isPackaged).to.equal(false);
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.isPackaged).to.equal(false);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('should be false during tests', () => {
expect(app.isInApplicationsFolder()).to.equal(false);
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(app.isInApplicationsFolder()).to.equal(false);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
let appProcess: cp.ChildProcess | null = null;
afterEach(() => {
if (appProcess) appProcess.kill();
});
it('emits a process exit event with the code', async () => {
const appPath = path.join(fixturesPath, 'api', 'quit-app');
const electronPath = process.execPath;
let output = '';
appProcess = cp.spawn(electronPath, [appPath]);
if (appProcess && appProcess.stdout) {
appProcess.stdout.on('data', data => { output += data; });
}
const [code] = await emittedOnce(appProcess, 'exit');
if (process.platform !== 'win32') {
expect(output).to.include('Exit event with code: 123');
}
expect(code).to.equal(123);
});
it('closes all windows', async function () {
const appPath = path.join(fixturesPath, 'api', 'exit-closes-all-windows-app');
const electronPath = process.execPath;
appProcess = cp.spawn(electronPath, [appPath]);
const [code, signal] = await emittedOnce(appProcess, 'exit');
expect(signal).to.equal(null, 'exit signal should be null, if you see this please tag @MarshallOfSound');
expect(code).to.equal(123, 'exit code should be 123, if you see this please tag @MarshallOfSound');
});
it('exits gracefully', async function () {
if (!['darwin', 'linux'].includes(process.platform)) {
this.skip();
return;
}
const electronPath = process.execPath;
const appPath = path.join(fixturesPath, 'api', 'singleton');
appProcess = cp.spawn(electronPath, [appPath]);
// Singleton will send us greeting data to let us know it's running.
// After that, ask it to exit gracefully and confirm that it does.
if (appProcess && appProcess.stdout) {
appProcess.stdout.on('data', () => appProcess!.kill());
}
const [code, signal] = await emittedOnce(appProcess, 'exit');
const message = `code:\n${code}\nsignal:\n${signal}`;
expect(code).to.equal(0, message);
expect(signal).to.equal(null, message);
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
if (appProcess) appProcess.kill();
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
async () => {
const appPath = path.join(fixturesPath, 'api', 'quit-app');
const electronPath = process.execPath;
let output = '';
appProcess = cp.spawn(electronPath, [appPath]);
if (appProcess && appProcess.stdout) {
appProcess.stdout.on('data', data => { output += data; });
}
const [code] = await emittedOnce(appProcess, 'exit');
if (process.platform !== 'win32') {
expect(output).to.include('Exit event with code: 123');
}
expect(code).to.equal(123);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
data => { output += data; } | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => appProcess!.kill() | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('throws an error on invalid application policies', () => {
expect(() => {
app.setActivationPolicy('terrible' as any);
}).to.throw(/Invalid activation policy: must be one of 'regular', 'accessory', or 'prohibited'/);
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
expect(() => {
app.setActivationPolicy('terrible' as any);
}).to.throw(/Invalid activation policy: must be one of 'regular', 'accessory', or 'prohibited'/);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
app.setActivationPolicy('terrible' as any);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
it('prevents the second launch of app', async function () {
this.timeout(120000);
const appPath = path.join(fixturesPath, 'api', 'singleton');
const first = cp.spawn(process.execPath, [appPath]);
await emittedOnce(first.stdout, 'data');
// Start second app when received output.
const second = cp.spawn(process.execPath, [appPath]);
const [code2] = await emittedOnce(second, 'exit');
expect(code2).to.equal(1);
const [code1] = await emittedOnce(first, 'exit');
expect(code1).to.equal(0);
});
it('passes arguments to the second-instance event', async () => {
const appPath = path.join(fixturesPath, 'api', 'singleton');
const first = cp.spawn(process.execPath, [appPath]);
const firstExited = emittedOnce(first, 'exit');
// Wait for the first app to boot.
const firstStdoutLines = first.stdout.pipe(split());
while ((await emittedOnce(firstStdoutLines, 'data')).toString() !== 'started') {
// wait.
}
const data2Promise = emittedOnce(firstStdoutLines, 'data');
const secondInstanceArgs = [process.execPath, appPath, '--some-switch', 'some-arg'];
const second = cp.spawn(secondInstanceArgs[0], secondInstanceArgs.slice(1));
const [code2] = await emittedOnce(second, 'exit');
expect(code2).to.equal(1);
const [code1] = await firstExited;
expect(code1).to.equal(0);
const data2 = (await data2Promise)[0].toString('ascii');
const secondInstanceArgsReceived: string[] = JSON.parse(data2.toString('ascii'));
const expected = process.platform === 'win32'
? [process.execPath, '--some-switch', '--allow-file-access-from-files', appPath, 'some-arg']
: secondInstanceArgs;
expect(secondInstanceArgsReceived).to.eql(expected,
`expected ${JSON.stringify(expected)} but got ${data2.toString('ascii')}`);
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
async () => {
const appPath = path.join(fixturesPath, 'api', 'singleton');
const first = cp.spawn(process.execPath, [appPath]);
const firstExited = emittedOnce(first, 'exit');
// Wait for the first app to boot.
const firstStdoutLines = first.stdout.pipe(split());
while ((await emittedOnce(firstStdoutLines, 'data')).toString() !== 'started') {
// wait.
}
const data2Promise = emittedOnce(firstStdoutLines, 'data');
const secondInstanceArgs = [process.execPath, appPath, '--some-switch', 'some-arg'];
const second = cp.spawn(secondInstanceArgs[0], secondInstanceArgs.slice(1));
const [code2] = await emittedOnce(second, 'exit');
expect(code2).to.equal(1);
const [code1] = await firstExited;
expect(code1).to.equal(0);
const data2 = (await data2Promise)[0].toString('ascii');
const secondInstanceArgsReceived: string[] = JSON.parse(data2.toString('ascii'));
const expected = process.platform === 'win32'
? [process.execPath, '--some-switch', '--allow-file-access-from-files', appPath, 'some-arg']
: secondInstanceArgs;
expect(secondInstanceArgsReceived).to.eql(expected,
`expected ${JSON.stringify(expected)} but got ${data2.toString('ascii')}`);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
let server: net.Server | null = null;
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch';
beforeEach(done => {
fs.unlink(socketPath, () => {
server = net.createServer();
server.listen(socketPath);
done();
});
});
afterEach((done) => {
server!.close(() => {
if (process.platform === 'win32') {
done();
} else {
fs.unlink(socketPath, () => done());
}
});
});
it('relaunches the app', function (done) {
this.timeout(120000);
let state = 'none';
server!.once('error', error => done(error));
server!.on('connection', client => {
client.once('data', data => {
if (String(data) === 'false' && state === 'none') {
state = 'first-launch';
} else if (String(data) === 'true' && state === 'first-launch') {
done();
} else {
done(`Unexpected state: ${state}`);
}
});
});
const appPath = path.join(fixturesPath, 'api', 'relaunch');
cp.spawn(process.execPath, [appPath]);
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
done => {
fs.unlink(socketPath, () => {
server = net.createServer();
server.listen(socketPath);
done();
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
server = net.createServer();
server.listen(socketPath);
done();
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
(done) => {
server!.close(() => {
if (process.platform === 'win32') {
done();
} else {
fs.unlink(socketPath, () => done());
}
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
if (process.platform === 'win32') {
done();
} else {
fs.unlink(socketPath, () => done());
}
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
error => done(error) | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
client => {
client.once('data', data => {
if (String(data) === 'false' && state === 'none') {
state = 'first-launch';
} else if (String(data) === 'true' && state === 'first-launch') {
done();
} else {
done(`Unexpected state: ${state}`);
}
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
data => {
if (String(data) === 'false' && state === 'none') {
state = 'first-launch';
} else if (String(data) === 'true' && state === 'first-launch') {
done();
} else {
done(`Unexpected state: ${state}`);
}
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
before(function () {
if (process.platform !== 'darwin') {
this.skip();
}
});
it('sets the current activity', () => {
app.setUserActivity('com.electron.testActivity', { testData: '123' });
expect(app.getCurrentActivityType()).to.equal('com.electron.testActivity');
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
app.setUserActivity('com.electron.testActivity', { testData: '123' });
expect(app.getCurrentActivityType()).to.equal('com.electron.testActivity');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
afterEach(closeAllWindows);
it('is emitted when visiting a server with a self-signed cert', async () => {
const w = new BrowserWindow({ show: false });
w.loadURL(secureUrl);
await emittedOnce(app, 'certificate-error');
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
async () => {
const w = new BrowserWindow({ show: false });
w.loadURL(secureUrl);
await emittedOnce(app, 'certificate-error');
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => {
let w: BrowserWindow = null as any;
afterEach(() => closeWindow(w).then(() => { w = null as any; }));
it('should emit browser-window-focus event when window is focused', async () => {
const emitted = emittedOnce(app, 'browser-window-focus');
w = new BrowserWindow({ show: false });
w.emit('focus');
const [, window] = await emitted;
expect(window.id).to.equal(w.id);
});
it('should emit browser-window-blur event when window is blured', async () => {
const emitted = emittedOnce(app, 'browser-window-blur');
w = new BrowserWindow({ show: false });
w.emit('blur');
const [, window] = await emitted;
expect(window.id).to.equal(w.id);
});
it('should emit browser-window-created event when window is created', async () => {
const emitted = emittedOnce(app, 'browser-window-created');
w = new BrowserWindow({ show: false });
const [, window] = await emitted;
expect(window.id).to.equal(w.id);
});
it('should emit web-contents-created event when a webContents is created', async () => {
const emitted = emittedOnce(app, 'web-contents-created');
w = new BrowserWindow({ show: false });
const [, webContents] = await emitted;
expect(webContents.id).to.equal(w.webContents.id);
});
// FIXME: re-enable this test on win32.
ifit(process.platform !== 'win32')('should emit renderer-process-crashed event when renderer crashes', async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const emitted = emittedOnce(app, 'renderer-process-crashed');
w.webContents.executeJavaScript('process.crash()');
const [, webContents] = await emitted;
expect(webContents).to.equal(w.webContents);
});
// FIXME: re-enable this test on win32.
ifit(process.platform !== 'win32')('should emit render-process-gone event when renderer crashes', async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const emitted = emittedOnce(app, 'render-process-gone');
w.webContents.executeJavaScript('process.crash()');
const [, webContents, details] = await emitted;
expect(webContents).to.equal(w.webContents);
expect(details.reason).to.be.oneOf(['crashed', 'abnormal-exit']);
});
ifdescribe(features.isDesktopCapturerEnabled())('desktopCapturer module filtering', () => {
it('should emit desktop-capturer-get-sources event when desktopCapturer.getSources() is invoked', async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const promise = emittedOnce(app, 'desktop-capturer-get-sources');
w.webContents.executeJavaScript('require(\'electron\').desktopCapturer.getSources({ types: [\'screen\'] })');
const [, webContents] = await promise;
expect(webContents).to.equal(w.webContents);
});
});
ifdescribe(features.isRemoteModuleEnabled())('remote module filtering', () => {
it('should emit remote-require event when remote.require() is invoked', async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const promise = emittedOnce(app, 'remote-require');
w.webContents.executeJavaScript('require(\'electron\').remote.require(\'test\')');
const [, webContents, moduleName] = await promise;
expect(webContents).to.equal(w.webContents);
expect(moduleName).to.equal('test');
});
it('should emit remote-get-global event when remote.getGlobal() is invoked', async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const promise = emittedOnce(app, 'remote-get-global');
w.webContents.executeJavaScript('require(\'electron\').remote.getGlobal(\'test\')');
const [, webContents, globalName] = await promise;
expect(webContents).to.equal(w.webContents);
expect(globalName).to.equal('test');
});
it('should emit remote-get-builtin event when remote.getBuiltin() is invoked', async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const promise = emittedOnce(app, 'remote-get-builtin');
w.webContents.executeJavaScript('require(\'electron\').remote.app');
const [, webContents, moduleName] = await promise;
expect(webContents).to.equal(w.webContents);
expect(moduleName).to.equal('app');
});
it('should emit remote-get-current-window event when remote.getCurrentWindow() is invoked', async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const promise = emittedOnce(app, 'remote-get-current-window');
w.webContents.executeJavaScript('{ require(\'electron\').remote.getCurrentWindow() }');
const [, webContents] = await promise;
expect(webContents).to.equal(w.webContents);
});
it('should emit remote-get-current-web-contents event when remote.getCurrentWebContents() is invoked', async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const promise = emittedOnce(app, 'remote-get-current-web-contents');
w.webContents.executeJavaScript('{ require(\'electron\').remote.getCurrentWebContents() }');
const [, webContents] = await promise;
expect(webContents).to.equal(w.webContents);
});
});
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => closeWindow(w).then(() => { w = null as any; }) | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
() => { w = null as any; } | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
async () => {
const emitted = emittedOnce(app, 'browser-window-focus');
w = new BrowserWindow({ show: false });
w.emit('focus');
const [, window] = await emitted;
expect(window.id).to.equal(w.id);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
async () => {
const emitted = emittedOnce(app, 'browser-window-blur');
w = new BrowserWindow({ show: false });
w.emit('blur');
const [, window] = await emitted;
expect(window.id).to.equal(w.id);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
async () => {
const emitted = emittedOnce(app, 'browser-window-created');
w = new BrowserWindow({ show: false });
const [, window] = await emitted;
expect(window.id).to.equal(w.id);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
async () => {
const emitted = emittedOnce(app, 'web-contents-created');
w = new BrowserWindow({ show: false });
const [, webContents] = await emitted;
expect(webContents.id).to.equal(w.webContents.id);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
ArrowFunction |
async () => {
w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
await w.loadURL('about:blank');
const emitted = emittedOnce(app, 'renderer-process-crashed');
w.webContents.executeJavaScript('process.crash()');
const [, webContents] = await emitted;
expect(webContents).to.equal(w.webContents);
} | fisabelle-lmi/electron | spec-main/api-app-spec.ts | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.