Skip to content

Commit 536d32a

Browse files
committed
Merge pull request #2 from OpenframeProject/tests
New structure, tests
2 parents f941fab + 82c320d commit 536d32a

7 files changed

Lines changed: 77 additions & 33 deletions

File tree

.eslintrc.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ rules:
4242
no-mixed-spaces-and-tabs: [1]
4343
# Allow but do not force dangling commas.
4444
comma-dangle: [0]
45-
# prefer object shorthand for new object creation (i.e. var a = {};)
46-
object-shorthand: [2, always]
4745
# use single quotes
4846
quotes: [2, single]
4947
# use semicolons to end statements
@@ -73,6 +71,7 @@ env:
7371
node: true
7472
# allow commonjs module definition globals (e.g. require, module.exports)
7573
commonjs: true
74+
mocha: true
7675

7776

7877

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
node_js:
3+
- "4"
4+
- "5"
5+
6+
notifications:
7+
slack: openframeproject:wGLUMLh5CTAIOGsPUSU8eMf3
8+
9+
# A bit annoying, but we manually install all npm deps so that the install.sh script doesn't get executed on travis
10+
install:
11+
npm install coveralls@^2.11.9 eslint@^2.8.0 istanbul@^0.4.2 mocha@^2.3.4 sinon@^1.17.2 openframe-extension@^0.1.0 debug@^2.2.0
12+
13+
script:
14+
- npm run test-coveralls

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Openframe Website Extension
22

3+
[![Build Status](https://travis-ci.org/OpenframeProject/Openframe-Website.svg?branch=master)](https://travis-ci.org/OpenframeProject/Openframe-Website) [![Coverage Status](https://coveralls.io/repos/github/OpenframeProject/Openframe-Website/badge.svg?branch=master)](https://coveralls.io/github/OpenframeProject/Openframe-Website?branch=master)
4+
35
An Openframe format extension which enables display of websites via chromium.
46

57
For info on developing your own extensions, see the [Openframe-ExtensionExample](https://github.com/OpenframeProject/Openframe-ExtensionExample) repo.

extension.js

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
11
var pjson = require('./package.json'),
2-
debug = require('debug')('openframe:website'),
3-
extension = module.exports = {};
2+
Extension = require('openframe-extension');
43

54
/**
6-
* Extension initialization method.
5+
* Extensions should expose an instance of the Extension class.
76
*
8-
* Called when the extension (and its dependencies) have been installed.
9-
*
10-
* @param {object} OF An interface provided to extensions giving limitted access to the frame environment
7+
* For info on building extensions, see [Openframe-Extension](https://github.com/OpenframeProject/Openframe-Extension).
118
*/
12-
extension.init = function(OF) {
13-
// do your extension thing
14-
debug('=======> Openframe-Website initialized! <=======');
15-
16-
/**
17-
* Extensions can add new artwork formats to the frame.
18-
*
19-
* Each format must have a unique name, which should correspond to the
20-
* name of the npm package.
21-
*/
22-
OF.addFormat(
23-
{
24-
// the name should be the same as the package name
25-
'name': pjson.name,
26-
// this is what might get displayed to users (not currently used)
27-
'display_name': 'Website',
28-
'download': false,
29-
'start_command': 'xinit /usr/bin/chromium --kiosk $url',
30-
'end_command': 'sudo pkill -f chromium'
31-
}
32-
);
33-
};
34-
9+
module.exports = new Extension({
10+
format: {
11+
// the name should be the same as the package name
12+
'name': pjson.name,
13+
// this is what might get displayed to users (not currently used)
14+
'display_name': 'Website',
15+
'download': false,
16+
'start_command': 'xinit /usr/bin/chromium --kiosk $url',
17+
'end_command': 'sudo pkill -f chromium'
18+
}
19+
});

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77
"install": "./install.sh",
88
"uninstall": "./uninstall.sh",
99
"patch-release": "npm version patch && npm publish && git push --follow-tags",
10-
"test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha"
10+
"lint": "./node_modules/.bin/eslint extension.js test/**",
11+
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
12+
"test": "npm run lint && ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha",
13+
"test-coveralls": "npm run lint && ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -R spec && npm run coveralls"
1114
},
1215
"keywords": [
1316
"openframe",
17+
"extension",
18+
"format",
19+
"website",
20+
"openframe-extension",
1421
"openframe-website",
15-
"format"
22+
"chromium"
1623
],
1724
"author": {
1825
"name": "Jonathan Wohl",
@@ -30,6 +37,8 @@
3037
],
3138
"license": "GPL-3.0",
3239
"devDependencies": {
40+
"coveralls": "^2.11.9",
41+
"eslint": "^2.8.0",
3342
"istanbul": "^0.4.2",
3443
"mocha": "^2.3.4",
3544
"sinon": "^1.17.2"
@@ -39,6 +48,7 @@
3948
"url": "https://github.com/OpenframeProject/Openframe-Website"
4049
},
4150
"dependencies": {
51+
"openframe-extension": "^0.1.0",
4252
"debug": "^2.2.0"
4353
}
4454
}

test/extension.spec.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var assert = require('assert'),
2+
Extension = require('openframe-extension'),
3+
WebsiteExtension = require('../extension');
4+
5+
describe('instantiation', function() {
6+
it('should be an instance of type Extension', function() {
7+
assert(WebsiteExtension instanceof Extension);
8+
});
9+
});
10+
11+
describe('properties', function() {
12+
it('should include all required format properties', function() {
13+
var format = WebsiteExtension.props.format;
14+
15+
assert(format.name);
16+
assert(typeof format.name === 'string');
17+
18+
assert(format.display_name);
19+
assert(typeof format.display_name === 'string');
20+
21+
assert(format.download !== undefined);
22+
assert(typeof format.download === 'boolean');
23+
24+
assert(format.start_command);
25+
assert(typeof format.start_command === 'string' || typeof format.start_command === 'function');
26+
27+
if (typeof format.start_command === 'function') {
28+
assert(typeof format.start_command() === 'string');
29+
}
30+
31+
assert(format.end_command);
32+
assert(typeof format.end_command === 'string');
33+
});
34+
});

test/plugin.spec.js

Whitespace-only changes.

0 commit comments

Comments
 (0)