-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b18e4d2
Showing
14 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Test against the latest version of this Node.js version | ||
environment: | ||
nodejs_version: "6" | ||
|
||
# Install scripts. (runs after repo cloning) | ||
install: | ||
# Get the latest stable version of Node.js or io.js | ||
- ps: Install-Product node $env:nodejs_version | ||
# install modules | ||
- npm install | ||
|
||
# Post-install test scripts. | ||
test_script: | ||
# Output useful info for debugging. | ||
- node --version | ||
- npm --version | ||
# run tests | ||
- npm run build | ||
|
||
# Don't actually build. | ||
build: off |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"presets": ["env"], | ||
"env": { | ||
"test": { | ||
"plugins": ["istanbul"] | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules/ | ||
/coverage/ | ||
/lib/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
extends: 'google', | ||
env: { | ||
node: true, | ||
es6: true | ||
}, | ||
rules: { | ||
'no-unused-vars': [2, {'args': 'after-used', 'argsIgnorePattern': '^_', 'varsIgnorePattern': '^_'}], | ||
'require-jsdoc': 0 | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 8, | ||
sourceType: 'module' | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/.alarmist/ | ||
/npm-debug.log | ||
/node_modules/ | ||
/coverage/ | ||
/.nyc_output/ | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"check-coverage": false, | ||
"lines": 100, | ||
"statements": 100, | ||
"functions": 100, | ||
"branches": 100, | ||
"watermarks": { | ||
"lines": [100, 100], | ||
"statements": [100, 100], | ||
"functions": [100, 100], | ||
"branches": [100, 100] | ||
}, | ||
"reporter": [ | ||
"lcov" | ||
], | ||
"require": [ | ||
"babel-register" | ||
], | ||
"sourceMap": false, | ||
"instrument": false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- '5' | ||
- '6' | ||
- 'stable' | ||
script: npm run ci |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# forgiven-webcomponents | ||
|
||
[![Build Status](https://travis-ci.org/pghalliday/forgiven-webcomponents.svg?branch=master)](https://travis-ci.org/pghalliday/forgiven-webcomponents) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/8jaac5m0tgfwf283/branch/master?svg=true)](https://ci.appveyor.com/project/pghalliday/forgiven-webcomponents/branch/master) | ||
[![Coverage Status](https://coveralls.io/repos/github/pghalliday/forgiven-webcomponents/badge.svg?branch=master)](https://coveralls.io/github/pghalliday/forgiven-webcomponents?branch=master) | ||
|
||
[Forgiven](https://www.npmjs.com/package/forgiven) extensions for [web-component-tester](https://github.com/Polymer/web-component-tester) test-fixtures | ||
|
||
## Usage | ||
|
||
```shell | ||
npm install --save-dev web-component-tester forgiven forgiven-mocha forgiven-webcomponents | ||
``` | ||
|
||
```javascript | ||
import { | ||
create, | ||
} from 'forgiven'; | ||
import { | ||
mocha, | ||
} from 'forgiven-mocha'; | ||
import { | ||
webcomponents, | ||
} from 'forgiven-webcomponents'; | ||
|
||
global.given = create(mocha, { | ||
fixture: webcomponents, | ||
}); | ||
``` | ||
|
||
## Contributing | ||
|
||
Run unit tests and build before pushing/opening a pull request. | ||
|
||
- `npm test` - lint and test | ||
- `npm start` - watch and build, etc with alarmist | ||
- `npm run build` - run tests then build | ||
- `npm run watch` - watch for changes and run build | ||
- `npm run ci` - run build and submit coverage to coveralls |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.webcomponents = webcomponents; | ||
|
||
var _forgiven = require('forgiven'); | ||
|
||
function webcomponents(setup) { | ||
return { | ||
as: function as(context, name) { | ||
var setupFixture = function setupFixture(conjunction, id, data) { | ||
return setup({ | ||
description: 'as `' + name + '` ' + conjunction + ' ' + id, | ||
beforeEach: function beforeEach(done) { | ||
var element = document.getElementbyId(id).create(data); | ||
element.record = { | ||
event: function event(_event) { | ||
return { | ||
as: function as(name) { | ||
element.addEventListener(_event, function (event) { | ||
context[name] = event; | ||
}); | ||
} | ||
}; | ||
}, | ||
events: function events(event) { | ||
return { | ||
as: function as(name) { | ||
context[name] = []; | ||
element.addEventListener(event, function (event) { | ||
context[name].push(event); | ||
}); | ||
} | ||
}; | ||
} | ||
}; | ||
element.promise = { | ||
event: function event(_event2) { | ||
return { | ||
as: function as(name) { | ||
context[name] = new Promise(function (resolve) { | ||
var listener = function listener(evt) { | ||
element.removeEventListener(_event2, listener); | ||
resolve(evt); | ||
}; | ||
element.addEventListener(_event2, listener); | ||
}); | ||
} | ||
}; | ||
} | ||
}; | ||
context[name] = element; | ||
flush(done); | ||
}, | ||
afterEach: function afterEach(done) { | ||
context[name].restore(); | ||
flush(done); | ||
} | ||
}); | ||
}; | ||
var chain = {}; | ||
_forgiven.SETUP_CONJUNCTIONS.forEach(function (conjunction) { | ||
chain[conjunction] = setupFixture.bind(null, conjunction); | ||
}); | ||
return next; | ||
} | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "forgiven-webcomponents", | ||
"version": "0.0.0", | ||
"description": "Forgiven extensions for web-component-tester test-fixtures", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"cmd:lint": "eslint .", | ||
"cmd:test": "cross-env NODE_ENV=test nyc mocha", | ||
"cmd:coverage": "nyc report -r text", | ||
"cmd:build": "babel src --out-dir lib", | ||
"cmd:coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"test": "run-s cmd:lint cmd:test cmd:coverage", | ||
"build": "run-s test cmd:build", | ||
"ci": "run-s build cmd:coveralls", | ||
"alarmist:lint": "chokidar \"+(src|test)/**/*\" -c \"alarmist-npm cmd:lint\"", | ||
"alarmist:test": "chokidar \"+(src|test)/**/*\" -c \"alarmist-npm cmd:test\"", | ||
"alarmist:coverage": "chokidar \"coverage/lcov.info\" -c \"alarmist-npm cmd:coverage\"", | ||
"alarmist:build": "chokidar \"src/**/*\" -c \"alarmist-npm cmd:build\"", | ||
"start": "alarmist-monitor run-p alarmist:lint alarmist:test alarmist:coverage alarmist:build", | ||
"watch": "chokidar '+(src|test)/**/*' -c 'npm run -s build'", | ||
"prepublish": "run-s cmd:build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/pghalliday/forgiven-webcomponents.git" | ||
}, | ||
"keywords": [], | ||
"author": "Peter Halliday <pghalliday@gmail.com> (http://pghalliday.com)", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/pghalliday/forgiven-webcomponents/issues" | ||
}, | ||
"homepage": "https://github.com/pghalliday/forgiven-webcomponents#readme", | ||
"devDependencies": { | ||
"alarmist": "^1.0.17", | ||
"alarmist-npm": "^1.0.4", | ||
"babel-cli": "^6.22.2", | ||
"babel-plugin-istanbul": "^3.1.2", | ||
"babel-preset-env": "^1.1.8", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^6.0.0", | ||
"chokidar-cli": "^1.2.0", | ||
"coveralls": "^2.11.15", | ||
"cross-env": "^3.1.4", | ||
"eslint": "^3.14.1", | ||
"eslint-config-google": "^0.7.1", | ||
"forgiven": "0.0.1", | ||
"mocha": "^3.2.0", | ||
"npm-run-all": "^4.0.1", | ||
"nyc": "^10.1.2", | ||
"sinon": "^2.0.0", | ||
"sinon-chai": "^2.8.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { | ||
SETUP_CONJUNCTIONS, | ||
} from 'forgiven'; | ||
|
||
export function webcomponents(setup) { | ||
return { | ||
as: function(context, name) { | ||
const setupFixture = (conjunction, id, data) => { | ||
return setup({ | ||
description: 'as `' + name + '` ' + conjunction + ' ' + id, | ||
beforeEach: (done) => { | ||
const element = document.getElementbyId(id).create(data); | ||
element.record = { | ||
event: (event) => { | ||
return { | ||
as: (name) => { | ||
element.addEventListener(event, (event) => { | ||
context[name] = event; | ||
}); | ||
}, | ||
}; | ||
}, | ||
events: (event) => { | ||
return { | ||
as: (name) => { | ||
context[name] = []; | ||
element.addEventListener(event, (event) => { | ||
context[name].push(event); | ||
}); | ||
}, | ||
}; | ||
}, | ||
}; | ||
element.promise = { | ||
event: (event) => { | ||
return { | ||
as: (name) => { | ||
context[name] = new Promise((resolve) => { | ||
const listener = (evt) => { | ||
element.removeEventListener(event, listener); | ||
resolve(evt); | ||
}; | ||
element.addEventListener(event, listener); | ||
}); | ||
}, | ||
}; | ||
}, | ||
}; | ||
context[name] = element; | ||
flush(done); | ||
}, | ||
afterEach: (done) => { | ||
context[name].restore(); | ||
flush(done); | ||
}, | ||
}); | ||
}; | ||
const chain = {}; | ||
SETUP_CONJUNCTIONS.forEach((conjunction) => { | ||
chain[conjunction] = setupFixture.bind(null, conjunction); | ||
}); | ||
return next; | ||
}, | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test/src | ||
--recursive | ||
--require test/setup |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// polyfills | ||
import 'babel-polyfill'; | ||
|
||
// assertions | ||
import chai from 'chai'; | ||
import sinon from 'sinon'; | ||
import sinonChai from 'sinon-chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
chai.use(sinonChai); | ||
chai.use(chaiAsPromised); | ||
chai.should(); | ||
global.expect = chai.expect; | ||
global.sinon = sinon; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { | ||
webcomponents, | ||
} from '../../src'; | ||
|
||
describe('forgiven-webcomponents', () => { | ||
it('should export the webcomponents plugin', () => { | ||
webcomponents.should.be.ok; | ||
}); | ||
|
||
// TODO: this is an initial import of something that was working | ||
// more integration tests need to be created | ||
}); |