Skip to content

Instantly share code, notes, and snippets.

@kentcdodds
Last active November 25, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kentcdodds/5b48e47a87fa9448802a to your computer and use it in GitHub Desktop.
Save kentcdodds/5b48e47a87fa9448802a to your computer and use it in GitHub Desktop.
ng-nebraska talk files - Services - The Importance of Learning JavaScript and staying Marketable
export default {flatten}
function flatten(array) {
return array.reduce((a, b) => a.concat(b), [])
}
import angular from 'angular'
import emojiUtils from './emojiUtils'
angular.module('emojiApp')
.factory('emojiUtils', () => emojiUtils)
angular.module('emojiApp')
.factory('emojiUtils', emojiUtils)
function emojiUtils() {
return {flatten}
function flatten(array) {
return array.reduce((a, b) => a.concat(b), [])
}
}
describe('emojiUtils', function() {
beforeEach(module('emojiApp'))
beforeEach(inject(function(_emojiUtils_) {
emojiUtils = _emojiUtils_
})
describe('flatten', function() {
const {flatten} = emojiUtils
it('should flatten an array', function() {
const input = [[1], [2, 3], [4]]
const result = [1, 2, 3, 4]
expect(flatten(input)).to.deep.equal(result)
})
})
})
import emojiUtils from './emojiUtils'
describe('emojiUtils', function() {
describe('flatten', function() {
const {flatten} = emojiUtils
it('should flatten an array', function() {
const input = [[1], [2, 3], [4]]
const result = [1, 2, 3, 4]
expect(flatten(input)).to.deep.equal(result)
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment