Last active
March 6, 2016 16:11
-
-
Save beevelop/f5cf1ff76d33e8d40713 to your computer and use it in GitHub Desktop.
Node.js helpers
This file contains hidden or 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
engines: | |
csslint: | |
enabled: true | |
duplication: | |
enabled: true | |
config: | |
languages: | |
- javascript | |
eslint: | |
enabled: true | |
fixme: | |
enabled: true | |
ratings: | |
paths: | |
- "**.css" | |
- "**.inc" | |
- "**.js" | |
- "**.jsx" | |
- "**.module" | |
- "**.php" | |
- "**.py" | |
- "**.rb" | |
exclude_paths: | |
- static/**/* | |
- test.js |
This file contains hidden or 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
language: node_js | |
node_js: | |
- "4.1" | |
addons: | |
code_climate: | |
repo_token: lskksl | |
before_install: npm i -g codeclimate-test-reporter | |
script: | |
- npm run init | |
- npm test | |
- npm run coverage | |
after_script: | |
- codeclimate-test-reporter < coverage/lcov.info |
This file contains hidden or 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
'use strict' | |
const Nodepoleon = require('../lib/nodepoleon') | |
var nodepoleon = new Nodepoleon() | |
var chai = require('chai') | |
var expect = chai.expect | |
chai.use(require('chai-as-promised')) | |
/* global describe, it */ | |
describe('Nodepolenon#hash', () => { | |
it('should return a valid hash', () => { | |
var hash = nodepoleon.hash(0) | |
expect(hash).to.be.a.string | |
expect(hash).to.have.lengthOf(4) | |
}) | |
it('should return a valid id', () => { | |
var id = nodepoleon.id(nodepoleon.hash(42)) | |
expect(id).to.equal(42) | |
}) | |
it('should save the provided url', async () => { | |
var hash = await nodepoleon.add('https://beevelop.com') | |
expect(hash).to.be.equal(nodepoleon.hash(1)) | |
}) | |
it('should fail for invalid urls', () => { | |
var hash = nodepoleon.add('invalid') | |
return expect(hash).to.be.rejectedWith('Invalid URI') | |
}) | |
it('should get a save and retrieve url', async () => { | |
var url = 'https://beevelop.com' | |
var req = await nodepoleon.add(url).then((hash) => { | |
return nodepoleon.get(hash) | |
}) | |
expect(req).to.be.equal(url) | |
}) | |
}) |
This file contains hidden or 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
{ | |
"scripts": { | |
"init": "npm i", | |
"postinstall": "./node_modules/.bin/bower install", | |
"start": "node lib/server.js", | |
"test": "./node_modules/.bin/mocha --harmony-proxies --compilers js:babel-core/register", | |
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/mocha -- --harmony-proxies --compilers js:babel-core/register -R spec", | |
"clean": "rm -rf node_modules static/libs coverage" | |
}, | |
"engines": { | |
"node": "4.x", | |
"npm": "3.x" | |
}, | |
"babel": { | |
"plugins": [ | |
"transform-async-to-generator", | |
"transform-es2015-destructuring", | |
"transform-es2015-parameters" | |
] | |
}, | |
"devDependencies": { | |
"babel-core": "^6.6.5", | |
"babel-plugin-transform-async-to-generator": "^6.5.0", | |
"babel-plugin-transform-es2015-destructuring": "^6.6.5", | |
"babel-plugin-transform-es2015-parameters": "^6.6.5", | |
"chai": "^3.5.0", | |
"chai-as-promised": "^5.2.0", | |
"istanbul": "^0.4.2", | |
"mocha": "^2.4.5", | |
"standard": "^6.0.7" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment