-
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
e40c109
commit bbd52c5
Showing
6 changed files
with
145 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
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.gs').QuickDrive; | ||
var QuickDrive = QuickDriveConstructor(DriveApp(), SpreadsheetApp()); | ||
var chai = require('chai'); | ||
var assert = chai.assert; | ||
var expect = chai.expect; | ||
|
||
var matrixMockWithReplaceAnnotations = [ | ||
[new Cell('{*this.propertyCell}'), new Cell('{*this.anotherPropertyCell}')], | ||
[new Cell('{*this.long.obj.reference.cell}'), new Cell('')] | ||
]; | ||
|
||
var jsonMock = { | ||
propertyCell: { | ||
value: 'The value', | ||
backgroundColor: 'rgb(100,100,100)', | ||
color: '#F00', | ||
textSize: 23, | ||
borderStyle: 'DOTTED', | ||
borderColor: '#00F', | ||
}, | ||
anotherPropertyCell: { | ||
value: 'my second value', | ||
color: '#F00', | ||
borderColor: '#00F' | ||
}, | ||
long: { | ||
obj: { | ||
reference: { | ||
cell: { | ||
value: '', | ||
textSize: 10, | ||
borderColor: '#00F' | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
describe('QuickDrive functions', function () { | ||
describe('get new sheet', function () { | ||
it('it should return sheet with text replaced', function () { | ||
var QuickDriveMock = QuickDriveConstructor(DriveApp(), SpreadsheetApp(matrixMockWithReplaceAnnotations)); | ||
var file = QuickDriveMock.processSheet(jsonMock); | ||
var range = file.sheet.getRange(1,1,2,2).getCells(); | ||
var firstCell = range[0][0]; | ||
var secondCell = range[0][1]; | ||
var thirdCell = range[1][0]; | ||
assert.equal('the value', firstCell.getValue()); | ||
assert.equal('rgb(100,100,100)', firstCell.getBackgroundColor()); | ||
assert.equal('#F00', firstCell.getColor()); | ||
assert.equal(23, firstCell.getTextSize()); | ||
assert.equal('DOTTED', firstCell.getBorderStyle()); | ||
assert.equal('#00F', firstCell.getBorderColor()); | ||
|
||
assert.equal('my second value', secondCell.getValue()); | ||
assert.equal('default', secondCell.getBackgroundColor()); | ||
assert.equal('#F00', secondCell.getColor()); | ||
assert.equal('default', secondCell.getTextSize()); | ||
assert.equal('SOLID', secondCell.getBorderStyle()); | ||
assert.equal('#00F', secondCell.getBorderColor()); | ||
|
||
assert.equal('', thirdCell.getValue()); | ||
assert.equal('default', thirdCell.getBackgroundColor()); | ||
assert.equal('default', thirdCell.getColor()); | ||
assert.equal(10, thirdCell.getTextSize()); | ||
assert.equal('SOLID', thirdCell.getBorderStyle()); | ||
assert.equal('#00F', thirdCell.getBorderColor()); | ||
}); | ||
}); | ||
}); |
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,66 @@ | ||
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.gs').QuickDrive; | ||
var QuickDrive = QuickDriveConstructor(DriveApp(), SpreadsheetApp()); | ||
var chai = require('chai'); | ||
var assert = chai.assert; | ||
var expect = chai.expect; | ||
|
||
var matrixMockWithReplaceAnnotations = [ | ||
[new Cell('{=this.reportHeader}'), new Cell('My random text'), new Cell('another random text'), new Cell('')], | ||
[new Cell('{=this.user.name}'), new Cell('{=this.user.lastName}'), new Cell('{=this.user.age}'), new Cell('My user')], | ||
[new Cell('{=this.user.address.cep}'), new Cell('{=this.user.address.city.name}'), new Cell('{=this.user.address.city.state.name}'), new Cell('{=this.user.address.city.state.country.name}')], | ||
[new Cell('Languages that he likes'), new Cell(''), new Cell(''), new Cell('')], | ||
[new Cell('{~this.curriculum.languagesThatLikes : languages}'), new Cell('{=languages}'), new Cell('{~}'), new Cell('text that will stay on last line')] | ||
]; | ||
|
||
var jsonMock = { | ||
reportHeader: 'My cool header', | ||
user: { | ||
name: 'Matheus', | ||
lastName: 'Martins do Rego', | ||
age: 20, | ||
address: { | ||
cep: '12345-678', | ||
city: { | ||
name: 'Campinas', | ||
state: { | ||
name: 'São Paulo', | ||
country: { | ||
name: 'Brasil' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
curriculum: { | ||
yearsWorking: 3, | ||
languagesThatLikes: [ | ||
'Java', | ||
'JavaScript', | ||
'CSS', | ||
'HTML', | ||
'Python' | ||
] | ||
} | ||
}; | ||
describe('QuickDrive functions', function () { | ||
describe('get new sheet', function () { | ||
it('it should return sheet with text replaced', function () { | ||
var QuickDriveMock = QuickDriveConstructor(DriveApp(), SpreadsheetApp(matrixMockWithReplaceAnnotations)); | ||
var file = QuickDriveMock.processSheet(jsonMock); | ||
assert.equal(JSON.stringify([ | ||
['My cool header', 'My random text', 'another random text', ''], | ||
['Matheus', 'Martins do Rego', 20, 'My user'], | ||
['12345-678', 'Campinas', 'São Paulo', 'Brasil'], | ||
['Languages that he likes', '', '', ''], | ||
['', 'Java', '', ''], | ||
['', 'JavaScript', '', ''], | ||
['', 'CSS', '', ''], | ||
['', 'HTML', '', ''], | ||
['', 'Python', '', 'text that will stay on last line'] | ||
]), JSON.stringify(file.sheet.getRange(1, 1, file.sheet.getMaxRows(), file.sheet.getMaxColumns()).getValues())); | ||
}); | ||
}); | ||
}); |
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