Skip to content
This repository has been archived by the owner on Oct 3, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Hassan Khan committed Sep 26, 2014
2 parents dce18b2 + 6e903a6 commit e58364b
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 27 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
language: node_js
node_js:
- "0.10"
before_install: npm install -g grunt-cli
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Contributing
===

## Prerequisites

1. Install the appropriate [EditorConfig](http://editorconfig.org) plugin for your IDE / editor. This helps keep the code style consistent.
2. Install [PhantomJS](http://phantomjs.org). Make sure it's on your path / available when calling `phantomjs` from the command line.
2. `npm install -g grunt-cli`
3. `npm install`

## Running the tests

- All tests: `npm test`
- Just the browser ones: `phantomjs phantom.js`
- Just the Node ones: `grunt test-node`

## Before creating the pull-request

Make sure you do the following:

- Run `grunt`

Note: The build script will generate new `*.min.{css,js}` files. If, for example, you only changed the JavaScript then don't bother committing `emojify.min.css`.

## Publishing

If you have rights to publish to npm, do the following first:

- Run `update.sh`. This will update the project with the latest emoji from [emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com).
- Run `grunt`
11 changes: 10 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,24 @@ module.exports = function (grunt) {
'emojify-emoticons.css': 'images/emoji/{blush,scream,smirk,smiley,stuck_out_tongue_closed_eyes,stuck_out_tongue_winking_eye,rage,disappointed,sob,kissing_heart,wink,pensive,confounded,flushed,relaxed,mask,heart,broken_heart}.png'
}
}
},
mochaTest: {
test: {
options: {
reporter: 'spec'
},
src: ['tests/node/*.js']
}
}
});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-datauri');


grunt.registerTask('test-node', 'mochaTest');
grunt.registerTask(
'default',
[
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ To set configuration options, use `emojify.setConfig()` and a JSON object as a p
}
});
emojify.run();

## Contributing

## Updating the emoji
From time to time, the emoji at [emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com) will be updated. Running the
`update.sh` script will update the project with the latest emoji. Don't forget to run grunt after running the update script.
See our [CONTRIBUTING.md](CONTRIBUTING.md).

[travis]: https://travis-ci.org/hassankhan/emojify.js
[package-bower]: http://bower.io/search/?q=emojify.js
Expand All @@ -72,4 +72,4 @@ From time to time, the emoji at [emoji-cheat-sheet.com](http://www.emoji-cheat-s
[ico-license]: http://img.shields.io/npm/l/emojify.js.svg?style=flat
[ico-gitter]: https://badges.gitter.im/hassankhan/emojify.js.png
[license]: http://hassankhan.mit-license.org/
[gitter]: https://gitter.im/hassankhan/emojify.js
[gitter]: https://gitter.im/hassankhan/emojify.js
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A Javascript module to convert emoji keywords to images.",
"main": "emojify.js",
"scripts": {
"test": "phantomjs phantom.js"
"test": "grunt test-node && phantomjs phantom.js"
},
"repository": {
"type": "git",
Expand All @@ -27,7 +27,9 @@
"grunt-contrib-uglify": "~0.2.4",
"grunt-datauri": "^0.4.0",
"jstest": "~1.0.4",
"q": "^1.0.1"
"q": "^1.0.1",
"grunt-mocha-test": "~0.12.0",
"chai": "~1.9.1"
},
"testling": {
"html": "tests/browser.html",
Expand All @@ -41,5 +43,6 @@
"ipad/6..latest",
"android-browser/latest"
]
}
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion phantom.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ phantom.injectJs('./node_modules/jstest/jstest.js');
var options = {format: 'dot'},
reporter = new JS.Test.Reporters.Headless(options);

reporter.open('./tests/browser.html');
reporter.open('./tests/browser/browser.html');
14 changes: 0 additions & 14 deletions tests/browser.html

This file was deleted.

14 changes: 14 additions & 0 deletions tests/browser/browser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jstest</title>
</head>
<body>

<script src="../../node_modules/jstest/jstest.js"></script>
<script>ROOT = '../..'</script>
<script src="runner.js"></script>

</body>
</html>
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/runner.js → tests/browser/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ var run = function() {
JS.Test.autorun();
};

var ROOT = JS.ENV.ROOT || '..';
var ROOT = JS.ENV.ROOT || '../..';
// JS.cache = false;

JS.load(ROOT + '/emojify.js',
ROOT + '/tests/string_spec.js',
ROOT + '/tests/dom_spec.js',
ROOT + '/tests/emojify_tag_type_spec.js',
ROOT + '/tests/browser/string_spec.js',
ROOT + '/tests/browser/dom_spec.js',
ROOT + '/tests/browser/emojify_tag_type_spec.js',
// add files here as the project grows
run);
File renamed without changes.
22 changes: 22 additions & 0 deletions tests/node/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var chai = require('chai'),
expect = chai.expect,
emojify;

describe('emojify in a Node environment', function(){

beforeEach(function(){
emojify = require('../../');
});

describe('.replace', function(){
it('should replace named emoji', function() {
var result = emojify.replace(':smile:');
expect(result).to.equal("<img title=':smile:' alt=':smile:' class='emoji' src='images/emoji/smile.png' align='absmiddle' />");
});

it('should replace two-character emoji', function(){
var result = emojify.replace(':)');
expect(result).to.equal("<img title=':smile:' alt=':smile:' class='emoji' src='images/emoji/smile.png' align='absmiddle' />");
});
});
});

0 comments on commit e58364b

Please sign in to comment.