Skip to content

Commit

Permalink
Remove slugToSiteName helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jjpaulino committed Nov 6, 2018
1 parent b1aa90d commit 8e178cc
Show file tree
Hide file tree
Showing 7 changed files with 1,670 additions and 1,719 deletions.
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ app.set('view engine', 'handlebars');

# Helpers

Currently **56 helpers** in **10 categories**:
Currently **55 helpers** in **10 categories**:


### arrays
Expand Down Expand Up @@ -84,7 +84,6 @@ Currently **56 helpers** in **10 categories**:
* [**extractImgWidth**](https://github.com/clay/handlebars#extractimgwidth--code--tests-) ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/extractImgWidth.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/extractImgWidth.test.js) )
* [**indexOf**](https://github.com/clay/handlebars#indexof--code--tests-) ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/indexOf.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/indexOf.test.js) )
* [**set**](https://github.com/clay/handlebars#set--code--tests-) ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/set.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/set.test.js) )
* [**slugToSiteName**](https://github.com/clay/handlebars#slugtositename--code--tests-) ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/slugToSiteName.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/slugToSiteName.test.js) )

### numbers

Expand Down Expand Up @@ -215,7 +214,7 @@ Add in article ads to list of components in an article
#### Params
* `content` _(array)_ the list of components in the article
* `articleData` _(object)_ the entire article's data, used to pull in the different ad units defined
* `afterComponent` _(string)_ the component type to insert the ad after
* `afterCmp` _(string)_ the component type to insert the ad after

**Returns** _(object)_ splash

Expand Down Expand Up @@ -572,22 +571,6 @@ set data into current context or other optional context/object<br /> _note:_ do
//=> "abc"
```

### slugToSiteName ( [code](https://github.com/clay/handlebars/blob/master/helpers/misc/slugToSiteName.js) | [tests](https://github.com/clay/handlebars/blob/master/helpers/misc/slugToSiteName.test.js) )

return comma-separated site names from comma-separated slugs

#### Params
* `slugs` _(string)_ comma-separated string of slugs

**Returns** _(string)_

#### Example

```hbs
{{ slugToSiteName (commaSeparated crosspost) }}
```

## numbers


Expand Down
6 changes: 3 additions & 3 deletions helpers/components/addInSplashAds.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function getComponentType(component) {
* Add in article ads to list of components in an article
* @param {array} content - the list of components in the article
* @param {object} articleData - the entire article's data, used to pull in the different ad units defined
* @param {string} afterComponent - the component type to insert the ad after
* @param {string} afterCmp - the component type to insert the ad after
* @return {object} splash
*/
module.exports = function (content, articleData, afterComponent) {
module.exports = function (content, articleData, afterCmp) {
var adUnits;

let newContent = []; // don't just replace the content (it's a sealed array), create a new array!
Expand All @@ -32,7 +32,7 @@ module.exports = function (content, articleData, afterComponent) {

// add the current component before any ads
newContent.push(component);
if (componentType === afterComponent) {
if (componentType === afterCmp) {
if (articleData.inSplashMobileAd) {
newContent.push(articleData.inSplashMobileAd);
}
Expand Down
15 changes: 15 additions & 0 deletions helpers/components/addInSplashAds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,19 @@ describe(name, function () {
expect(result[2]).to.equal(mediaplayComponent);
expect(result[3]).to.equal(paragraph1);
});

it('should not return the same content when the string passed in is not a component in the content', function () {
const result = filter([desktopAd, paragraph1, mediaplayComponent, paragraph1], { inSplashDesktopAd: desktopAd, inSplashTabletAd: tabletAd, inSplashMobileAd: mobileAd }, 'notAComponent');

expect(result[0]).to.equal(desktopAd);
expect(result[1]).to.equal(paragraph1);
expect(result[2]).to.equal(mediaplayComponent);
expect(result[3]).to.equal(paragraph1);
});

it('should just return the content if there are no ads', function () {
var result = filter([mobileAd, paragraph1, mediaplayComponent, paragraph1], {}, 'notAComponent');

expect(_.includes(result, mobileAd)).to.equal(true);
});
});
30 changes: 0 additions & 30 deletions helpers/misc/slugToSiteName.js

This file was deleted.

17 changes: 0 additions & 17 deletions helpers/misc/slugToSiteName.test.js

This file was deleted.

Loading

0 comments on commit 8e178cc

Please sign in to comment.