-
Notifications
You must be signed in to change notification settings - Fork 30
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
8bee3ad
commit 8be05e9
Showing
7 changed files
with
143 additions
and
16 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
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,81 @@ | ||
var chai = require('chai'); | ||
var path = require('path'); | ||
var fse = require('fs-extra'); | ||
|
||
var sourceAttr = require('../../../../src/cli/cms/editor/handlebars/sourceAttr') | ||
|
||
describe('cmsEditor.handlebars.sourceAttr', function() { | ||
before( function() { | ||
this.fixture = { | ||
gmapsElement: fse.readJsonSync(path.join(__dirname, '../../../fixtures/editor/gmaps-element.json'), 'utf8') | ||
} | ||
}); | ||
|
||
it('sourceAttr', function() { | ||
var obj = this.fixture.gmapsElement | ||
var params = { | ||
display:'{{formatted_address}}', | ||
value: 'State of Pará, Brazil' | ||
} | ||
var json = sourceAttr.default(obj, params) | ||
chai.expect(json.selected).to.equal('selected') | ||
chai.expect(json.val).to.equal('State of Pará, Brazil') | ||
}); | ||
|
||
it('get path', function() { | ||
var obj = this.fixture.gmapsElement | ||
var path = 'geometry.location.lat' | ||
var str = sourceAttr.get(obj, path) | ||
chai.expect(str).to.equal(-1.9981271) | ||
}); | ||
|
||
it('get unknown path', function() { | ||
var obj = this.fixture.gmapsElement | ||
var path = 'errored.path' | ||
var str = sourceAttr.get(obj, path) | ||
chai.expect(str).to.be.undefined; | ||
}); | ||
|
||
it('prepareDisplay value', function() { | ||
var obj = this.fixture.gmapsElement | ||
var str = 'formatted_address' | ||
str = sourceAttr.prepareDisplay(obj, str) | ||
chai.expect(str).to.equal('State of Pará, Brazil') | ||
}); | ||
|
||
it('prepareDisplay variable', function() { | ||
var obj = this.fixture.gmapsElement | ||
var str = '{{formatted_address}}' | ||
str = sourceAttr.prepareDisplay(obj, str) | ||
chai.expect(str).to.equal('State of Pará, Brazil') | ||
}); | ||
|
||
it('prepareDisplay 2 variables', function() { | ||
var obj = this.fixture.gmapsElement | ||
var str = '{{formatted_address}} - {{geometry.location.lat}}' | ||
str = sourceAttr.prepareDisplay(obj, str) | ||
chai.expect(str).to.equal('State of Pará, Brazil - -1.9981271') | ||
}); | ||
|
||
it('prepareDisplay unknown', function() { | ||
var obj = this.fixture.gmapsElement | ||
var str = 'unknownkey' | ||
str = sourceAttr.prepareDisplay(obj, str) | ||
chai.expect(str).to.equal(str) | ||
}); | ||
|
||
it('getKeys key', function() { | ||
var ar = sourceAttr.getKeys('key') | ||
chai.expect(ar.length).to.equal(1) | ||
}); | ||
|
||
it('getKeys {{key}}', function() { | ||
var ar = sourceAttr.getKeys('{{key}}') | ||
chai.expect(ar.length).to.equal(1) | ||
}); | ||
|
||
it('getKeys {{key}}-nokey-{{key2}}', function() { | ||
var ar = sourceAttr.getKeys('{{key}}-nokey-{{key2}}') | ||
chai.expect(ar.length).to.equal(2) | ||
}); | ||
}); |
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,53 @@ | ||
{ | ||
"address_components": [ | ||
{ | ||
"long_name": "State of Pará", | ||
"short_name": "PA", | ||
"types": [ | ||
"administrative_area_level_1", | ||
"political" | ||
] | ||
}, | ||
{ | ||
"long_name": "Brazil", | ||
"short_name": "BR", | ||
"types": [ | ||
"country", | ||
"political" | ||
] | ||
} | ||
], | ||
"formatted_address": "State of Pará, Brazil", | ||
"geometry": { | ||
"bounds": { | ||
"northeast": { | ||
"lat": 2.5910246, | ||
"lng": -46.0643195 | ||
}, | ||
"southwest": { | ||
"lat": -9.8411565, | ||
"lng": -58.89827700000001 | ||
} | ||
}, | ||
"location": { | ||
"lat": -1.9981271, | ||
"lng": -54.9306152 | ||
}, | ||
"location_type": "APPROXIMATE", | ||
"viewport": { | ||
"northeast": { | ||
"lat": 2.5910246, | ||
"lng": -46.0643195 | ||
}, | ||
"southwest": { | ||
"lat": -9.8411565, | ||
"lng": -58.89827700000001 | ||
} | ||
} | ||
}, | ||
"place_id": "ChIJlwksrJn5iJIRCvNV5z7IXjE", | ||
"types": [ | ||
"administrative_area_level_1", | ||
"political" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 +1,2 @@ | ||
console.log('test') | ||
//console.log('test') | ||
var i = 0 |
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