DefinitelyTyped/types/google-apps-script/google-apps-script-tests.ts
Wataru Yahiro 378ae65a04 add test
2018-08-09 00:46:19 +09:00

38 lines
1.2 KiB
TypeScript

// from https://developers.google.com/apps-script/overview
function createAndSendDocument() {
// Create a new Google Doc named 'Hello, world!'
var doc = DocumentApp.create('Hello, world!');
// Access the body of the document, then add a paragraph.
doc.getBody().appendParagraph('This document was created by Google Apps Script.');
// Get the URL of the document.
var url = doc.getUrl();
// Get the email address of the active user - that's you.
var email = Session.getActiveUser().getEmail();
// Get the name of the document to use as an email subject line.
var subject = doc.getName();
// Append a new string to the "url" variable to use as an email body.
var body = 'Link to your doc: ' + url;
// Send yourself an email with a link to the document.
GmailApp.sendEmail(email, subject, body);
}
// Regression
ScriptApp.getService().getUrl();
CalendarApp.GuestStatus.NO;
// test for URLFetchRequestOptions.payload
import URLFetchRequestOptions = GoogleAppsScript.URL_Fetch.URLFetchRequestOptions;
const postTest = (payload: Object): string => {
const url = 'http://httpbin.org/post';
const params: URLFetchRequestOptions = {
method: 'post',
payload: payload
};
return UrlFetchApp.fetch(url, params).getContentText();
};