-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2c82a2
commit dda9c2e
Showing
12 changed files
with
140 additions
and
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var SheetTemplater = require('./SheetTemplater.js').SheetTemplater; | ||
|
||
var QuickDrive = function (DriveApp, SpreadsheetApp) { | ||
this.SheetTemplater = function(config) { | ||
return new SheetTemplater(DriveApp, SpreadsheetApp, config); | ||
}; | ||
}; | ||
|
||
if (typeof module !== 'undefined' && module.exports != null) { | ||
exports.QuickDrive = QuickDrive; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function doPost(e) { | ||
var json = e ? JSON.parse(e.parameters.data[0]) : {}; | ||
var config = e ? (e.parameters.config ? JSON.parse(e.parameters.config[0]) : {}) : {}; | ||
var QuickDriveObj = new QuickDrive(DriveApp, SpreadsheetApp, config); | ||
var newFile = QuickDriveObj.processSheet(json); | ||
return ContentService.createTextOutput(newFile.fileId); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
describe('QuickDrive functions', function () { | ||
describe('validateConfig', function () { | ||
var createQuickDriveWithConfig = function (propertie, value) { | ||
var obj = {}; | ||
obj[propertie] = value; | ||
return function () { | ||
SheetTemplater.validateConfig(obj); | ||
}; | ||
}; | ||
it('it should have default config with no error', function () { | ||
SheetTemplater.validateConfig(SheetTemplater._config); | ||
}); | ||
it('it should validate fileId', function () { | ||
assert.throws(createQuickDriveWithConfig('templateId', 'myshortid'), Error, 'invalid-file-id'); | ||
assert.throws(createQuickDriveWithConfig('templateId', 2313123), Error, 'invalid-file-id'); | ||
assert.throws(createQuickDriveWithConfig('templateId', true), Error, 'invalid-file-id'); | ||
createQuickDriveWithConfig('fileId', '123456789012345678901234567890123456789012345')(); | ||
}); | ||
it('it should validate folderId', function () { | ||
assert.throws(createQuickDriveWithConfig('folderId', 'myshortid'), Error, 'invalid-folder-id'); | ||
assert.throws(createQuickDriveWithConfig('folderId', 2313123), Error, 'invalid-folder-id'); | ||
assert.throws(createQuickDriveWithConfig('folderId', true), Error, 'invalid-folder-id'); | ||
createQuickDriveWithConfig('folderId', '1234567890123456789012345678')(); | ||
}); | ||
it('it should validate file name', function () { | ||
assert.throws(createQuickDriveWithConfig('newDocumentName', 2313123), Error, 'invalid-file-name'); | ||
assert.throws(createQuickDriveWithConfig('newDocumentName', true), Error, 'invalid-file-name'); | ||
createQuickDriveWithConfig('newDocumentName', 'my new name')(); | ||
}); | ||
it('it should validate stripe color', function () { | ||
assert.throws(createQuickDriveWithConfig('stripeColor', 2313123), Error, 'invalid-stripe-color'); | ||
assert.throws(createQuickDriveWithConfig('stripeColor', true), Error, 'invalid-stripe-color'); | ||
assert.throws(createQuickDriveWithConfig('stripeColor', '#3333'), Error, 'invalid-stripe-color'); | ||
assert.throws(createQuickDriveWithConfig('stripeColor', '3333'), Error, 'invalid-stripe-color'); | ||
createQuickDriveWithConfig('stripeColor', '#333333')(); | ||
createQuickDriveWithConfig('stripeColor', '#333')(); | ||
createQuickDriveWithConfig('stripeColor', 'rgb(123,123,123)')(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,53 +1,4 @@ | ||
var DriveApp = require('./../mock/DriveApp.js').DriveApp; | ||
var Cell = require('./../mock/SpreadsheetApp/Cell.js').Cell; | ||
var SpreadsheetApp = require('./../mock/SpreadsheetApp.js').SpreadsheetApp; | ||
var QuickDriveConstructor = require('./../../src/SheetsTemplater.js').QuickDrive; | ||
var QuickDrive = new QuickDriveConstructor(DriveApp(), SpreadsheetApp()); | ||
var chai = require('chai'); | ||
var assert = chai.assert; | ||
var expect = chai.expect; | ||
|
||
describe('QuickDrive functions', function () { | ||
describe('validateConfig', function () { | ||
var createQuickDriveWithConfig = function (propertie, value) { | ||
var obj = {}; | ||
obj[propertie] = value; | ||
return function () { | ||
QuickDriveConstructor(DriveApp(), SpreadsheetApp(), obj); | ||
}; | ||
}; | ||
it('it should have default config with no error', function () { | ||
QuickDriveConstructor(DriveApp(), QuickDrive._config); | ||
}); | ||
it('it should validate fileId', function () { | ||
assert.throws(createQuickDriveWithConfig('templateId', 'myshortid'), Error, 'invalid-file-id'); | ||
assert.throws(createQuickDriveWithConfig('templateId', 2313123), Error, 'invalid-file-id'); | ||
assert.throws(createQuickDriveWithConfig('templateId', true), Error, 'invalid-file-id'); | ||
createQuickDriveWithConfig('fileId', '123456789012345678901234567890123456789012345')(); | ||
}); | ||
it('it should validate folderId', function () { | ||
assert.throws(createQuickDriveWithConfig('folderId', 'myshortid'), Error, 'invalid-folder-id'); | ||
assert.throws(createQuickDriveWithConfig('folderId', 2313123), Error, 'invalid-folder-id'); | ||
assert.throws(createQuickDriveWithConfig('folderId', true), Error, 'invalid-folder-id'); | ||
createQuickDriveWithConfig('folderId', '123456789012345678')(); | ||
}); | ||
it('it should validate file name', function () { | ||
assert.throws(createQuickDriveWithConfig('newDocumentName', 2313123), Error, 'invalid-file-name'); | ||
assert.throws(createQuickDriveWithConfig('newDocumentName', true), Error, 'invalid-file-name'); | ||
createQuickDriveWithConfig('newDocumentName', 'my new name')(); | ||
}); | ||
it('it should validate stripe color', function () { | ||
assert.throws(createQuickDriveWithConfig('stripeColor', 2313123), Error, 'invalid-stripe-color'); | ||
assert.throws(createQuickDriveWithConfig('stripeColor', true), Error, 'invalid-stripe-color'); | ||
assert.throws(createQuickDriveWithConfig('stripeColor', '#3333'), Error, 'invalid-stripe-color'); | ||
assert.throws(createQuickDriveWithConfig('stripeColor', '3333'), Error, 'invalid-stripe-color'); | ||
createQuickDriveWithConfig('stripeColor', '#333333')(); | ||
createQuickDriveWithConfig('stripeColor', '#333')(); | ||
createQuickDriveWithConfig('stripeColor', 'rgb(123,123,123)')(); | ||
}); | ||
}); | ||
}); | ||
|
||
require('./basicFunctions.js'); | ||
require('./sheetMockTest.js'); | ||
require('./annotations/mainTest.js'); | ||
require('./macro/mainTest.js'); | ||
require('./sheetMockTest.js'); | ||
require('./macro/mainTest.js'); |
Oops, something went wrong.