Last active
November 25, 2015 00:09
-
-
Save kentcdodds/1e22dbb029c71bed3a42 to your computer and use it in GitHub Desktop.
ng-nebraska talk files - Filters - The Importance of Learning JavaScript and staying Marketable
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
export default emojiGetter | |
function emojiGetter(emojiMap) { | |
return emojify | |
function emojify(emojiCode) { | |
return emojiMap[emojiCode] || emojiMap.confused | |
} | |
} |
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
import emojiGetter from './emoji-getter' | |
import emojiMap from './emoji-map' | |
const getEmoji = emojiGetter(emojiMap) | |
describe('emoji-getter', function() { | |
it('should default to the confused emoji', function() { | |
expect(emojiFilter()).to.equal('π') | |
expect(emojiFilter('gibberish')).to.equal('π') | |
}) | |
it('should return the right emoji for the emoji code', function() { | |
expect(emojiFilter('cherries')).to.equal('π') | |
}) | |
}) |
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
import angular from 'angular' | |
import emojiGetter from './emoji-getter' | |
import emojiMap from './emoji-map' | |
angular.module('emojiApp') | |
.factory('emoji', emojiGetter(emojiMap)) |
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
import angular from 'angular' | |
import emojiGetter from './emoji-getter' | |
import emojiMap from './emoji-map' | |
angular.module('emojiApp') | |
.filter('emoji', () => emojiGetter(emojiMap)) |
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
angular.module('emojiApp') | |
.filter('emoji', emojiFilter) | |
function emojiFilter(emojiMap) { | |
return emojify | |
function emojify(emojiCode) { | |
return emojiMap[emojiCode] || emojiMap.confused | |
} | |
} |
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
describe('emoji filter', function() { | |
beforeEach(module('emojiApp')) | |
var emojiFilter | |
beforeEach(inject($filter) { | |
emojiFilter = $filter('emoji') | |
}) | |
it('should default to the confused emoji', function() { | |
expect(emojiFilter()).to.equal('π') | |
expect(emojiFilter('gibberish')).to.equal('π') | |
}) | |
it('should return the right emoji for the emoji code', function() { | |
expect(emojiFilter('cherries')).to.equal('π') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment