├── .gitattributes
├── .gitignore
├── .jshintrc
├── .travis.yml
├── CONTRIBUTING.md
├── README.md
├── bower.json
├── filters
├── arrayFilter
│ ├── arrayFilter.js
│ └── arrayFilter.test.js
├── date
│ ├── date.js
│ └── date.test.js
├── length
│ ├── length.js
│ └── length.test.js
├── link
│ ├── link.js
│ └── link.test.js
├── lowercase
│ ├── lowercase.js
│ └── lowercase.test.js
├── replace
│ ├── replace.js
│ └── replace.test.js
├── reverse
│ ├── reverse.js
│ └── reverse.test.js
├── round
│ ├── round.js
│ └── round.test.js
├── trim
│ ├── trim.js
│ └── trim.test.js
└── uppercase
│ ├── uppercase.js
│ └── uppercase.test.js
├── index.html
├── karma.conf.js
├── package.json
├── poly-filters.html
└── test
├── karma-loader.js
└── test-component.html
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Coverage directory used by tools like istanbul
12 | coverage
13 |
14 | # Dependency directory
15 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
16 | node_modules
17 |
18 | # Bower components
19 | bower_components
20 |
21 | # Idea config files
22 | .idea
23 |
24 | # Coverage
25 | coverage
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "predef": {
3 | "PolymerExpressions":true,
4 | "describe": true,
5 | "it": true,
6 | "before": true,
7 | "beforeEach": true,
8 | "after": true,
9 | "afterEach": true,
10 | "module": true,
11 | "process": true
12 | }
13 | }
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - 0.10
4 | before_install:
5 | - npm install -g bower
6 | - bower install
7 | - export CHROME_BIN=chromium-browser
8 | - export DISPLAY=:99.0
9 | - sh -e /etc/init.d/xvfb start
10 |
11 | env:
12 | CODECLIMATE_REPO_TOKEN: 4f0d28dcf42f85e76c87593f3aa94573a0ff2189957421eadaa8b52e31700e54
13 |
14 | before_script:
15 | - npm install -g istanbul
16 | - npm install -g mocha
17 | - npm install -g codeclimate-test-reporter
18 |
19 | after_success:
20 | - istanbul cover _mocha -- -R spec ./filters/**/*.js
21 | - codeclimate < ./coverage/**/lcov.info
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # CONTRIBUTING to Poly-filters.
2 |
3 | 1. Create a new filter by analogy the length filter.
4 | 2. Pay attention on the template initialization.
5 | 3. testWrapper takes two arguments. The first is a object with a parameters that will be inject in the template.
6 | The second argument is a callback that returns the element with the parameter result.
7 | 4. When all tests have passed, add the filter in poly-filters.html and README.md.
8 | 5. Switch to the branch "gh-pages" and update the documentation for your filter.
9 | 6. PROFIT!!!!
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # poly-filters
2 |
3 | [](https://gitter.im/mbarinov/poly-filters?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4 |
7 |
8 |
9 |
10 |
11 | This library is a range of useful filters for Polymer expressions.
12 |
13 | [Documentation](http://mbarinov.github.io/poly-filters/)
14 |
15 | ## Getting started
16 |
17 | `bower install poly-filters`
18 |
19 | ``
20 |
21 | `{{ 'Hello world' | uppercase }}`
22 |
23 | `> HELLO WORLD`
24 |
25 | ## Filters:
26 |
27 | * Uppercase
28 | * Lowercase
29 | * Trim
30 | * Round
31 | * Reverse
32 | * Replace
33 | * Length
34 | * Parsing link
35 | * Date
36 | * Array filter
37 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "poly-filters",
3 | "version": "0.1.0",
4 | "homepage": "https://github.com/mbarinov/poly-filters",
5 | "keywords" : ["web-components", "polymer", "filters", "polymer expressions"],
6 | "authors": [
7 | "Maxim Barinov "
8 | ],
9 | "license": "MIT",
10 | "ignore": [
11 | "**/.*",
12 | "node_modules",
13 | "bower_components",
14 | "test",
15 | "tests"
16 | ],
17 | "dependencies": {
18 | "webcomponentsjs": "Polymer/webcomponentsjs#^0.5",
19 | "polymer": "Polymer/polymer#^0.5"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/filters/arrayFilter/arrayFilter.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.arrayFilter = function(input, prop, value, test) {
2 | var result = [];
3 |
4 | if(value === undefined || value === "") {
5 | return input;
6 | }
7 |
8 | if(input) {
9 | input.forEach(function (i) {
10 | if (i[prop].toLowerCase().indexOf(value.toLowerCase()) !== -1) {
11 | result.push(i);
12 | }
13 | });
14 | }
15 |
16 |
17 | if(test) {
18 | return JSON.stringify(result);
19 | } else {
20 | return result;
21 | }
22 |
23 | };
--------------------------------------------------------------------------------
/filters/arrayFilter/arrayFilter.test.js:
--------------------------------------------------------------------------------
1 | describe('Array filter', function () {
2 |
3 | var tmpl = '{{ value | arrayFilter(format, prop, true) }}';
4 |
5 | beforeEach(function (done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Search in array', function (done) {
11 |
12 | testWrapper({
13 | value: [
14 | {
15 | name: 'Addy Osmani'
16 | },
17 | {
18 | name: 'Paul Irish'
19 | },
20 | {
21 | name: 'Ryan Dahl'
22 | },
23 | {
24 | name: 'Sara Chipps'
25 | }
26 | ],
27 | format: 'name',
28 | prop: 'Paul Irish'
29 | },function (el) {
30 | el.result.should.equal('[{"name":"Paul Irish"}]');
31 | }, done);
32 |
33 | });
34 |
35 | it('Empty value', function (done) {
36 | testWrapper({
37 | value: [
38 | {
39 | name: 'Addy Osmani'
40 | },
41 | {
42 | name: 'Paul Irish'
43 | },
44 | {
45 | name: 'Ryan Dahl'
46 | },
47 | {
48 | name: 'Sara Chipps'
49 | }
50 | ],
51 | format: 'name',
52 | prop: ''
53 | },function (el) {
54 | el.result.should.be;
55 | }, done);
56 |
57 |
58 | });
59 |
60 |
61 | });
--------------------------------------------------------------------------------
/filters/date/date.js:
--------------------------------------------------------------------------------
1 | /*
2 | Stolen from polymer-filters by Addy Osmani ^_^
3 | http://addyosmani.github.io/polymer-filters/components/polymer-filters/
4 | */
5 |
6 | PolymerExpressions.prototype.date = function (input, format) {
7 | var date = new Date(input),
8 | day = date.getDate(),
9 | month = date.getMonth() + 1,
10 | year = date.getFullYear(),
11 | hours = date.getHours(),
12 | minutes = date.getMinutes(),
13 | seconds = date.getSeconds();
14 |
15 | if (!format) {
16 | format = "MM/dd/yyyy";
17 | }
18 |
19 | format = format.replace("MM", month.toString().replace(/^(\d)$/, '0$1'));
20 |
21 | var yearHandler = function () {
22 | if (format.indexOf("yyyy") > -1) {
23 | format = format.replace("yyyy", year.toString());
24 | } else if (format.indexOf("yy") > -1) {
25 | format = format.replace("yy", year.toString().substr(2, 2));
26 | }
27 | };
28 | var hhmmssHandler = function () {
29 | if (format.indexOf("hh") > -1) {
30 | if (hours > 12) {
31 | hours -= 12;
32 | }
33 | if (hours === 0) {
34 | hours = 12;
35 | }
36 | format = format.replace("hh", hours.toString().replace(/^(\d)$/, '0$1'));
37 | }
38 | if (format.indexOf("mm") > -1) {
39 | format = format.replace("mm", minutes.toString().replace(/^(\d)$/, '0$1'));
40 | }
41 | if (format.indexOf("ss") > -1) {
42 | format = format.replace("ss", seconds.toString().replace(/^(\d)$/, '0$1'));
43 | }
44 | format = format.replace("dd", day.toString().replace(/^(\d)$/, '0$1'));
45 | };
46 | var timeHandler = function () {
47 | if (format.indexOf("t") > -1) {
48 | if (hours > 11) {
49 | format = format.replace("t", "pm");
50 | } else {
51 | format = format.replace("t", "am");
52 | }
53 | }
54 | if (format.indexOf("HH") > -1) {
55 | format = format.replace("HH", hours.toString().replace(/^(\d)$/, '0$1'));
56 | }
57 | };
58 |
59 | yearHandler();
60 | timeHandler();
61 | hhmmssHandler();
62 |
63 | return format;
64 | };
--------------------------------------------------------------------------------
/filters/date/date.test.js:
--------------------------------------------------------------------------------
1 | describe('Date test', function () {
2 |
3 | var tmpl = '{{ value | date(format) }}';
4 |
5 | beforeEach(function(done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Correct length', function (done) {
11 |
12 | testWrapper({
13 | value: '2012-01-02'
14 | },function (el) {
15 | el.result.should.equal('01/02/2012');
16 | }, done);
17 |
18 | });
19 |
20 |
21 | it('format test yyyy-MM-dd HH:mm:ss Z', function (done) {
22 |
23 | testWrapper({
24 | value: '2012-01-02 07:00',
25 | format: 'yyyy-MM-dd HH:mm:ss Z'
26 | },function (el) {
27 | el.result.should.equal('2012-01-02 07:00:00 Z');
28 | }, done);
29 | });
30 |
31 | it('short year format', function (done) {
32 |
33 | testWrapper({
34 | value: '2012',
35 | format: 'yy'
36 | },function (el) {
37 | el.result.should.equal('12');
38 | }, done);
39 |
40 | });
41 |
42 | it('t format, am', function (done) {
43 |
44 | testWrapper({
45 | value: '2012-01-02 23:00',
46 | format: 't'
47 | },function (el) {
48 | el.result.should.equal('pm');
49 | }, done);
50 | });
51 |
52 | it('t format, pm', function (done) {
53 |
54 | testWrapper({
55 | value: '2012-01-02',
56 | format: 't'
57 | },function (el) {
58 | el.result.should.equal('am');
59 | }, done);
60 |
61 |
62 | });
63 |
64 |
65 | it('hh format, pm', function (done) {
66 |
67 | testWrapper({
68 | value: '2012-01-02 23:00',
69 | format: 'hh'
70 | },function (el) {
71 | el.result.should.equal('11');
72 | }, done);
73 |
74 | });
75 |
76 | it('hh format, 0:0', function (done) {
77 |
78 | testWrapper({
79 | value: '2012-01-02 0:0',
80 | format: 'hh'
81 | },function (el) {
82 | el.result.should.equal('12');
83 | }, done);
84 |
85 | });
86 |
87 | });
--------------------------------------------------------------------------------
/filters/length/length.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.length = function (input){
2 | return input.length;
3 | };
--------------------------------------------------------------------------------
/filters/length/length.test.js:
--------------------------------------------------------------------------------
1 | describe('Length test', function () {
2 |
3 | var tmpl = '{{ value | length }}';
4 |
5 | beforeEach(function(done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Correct length', function (done) {
11 | testWrapper(null, function (el) {
12 | parseInt(el.result).should.equal(4);
13 | }, done);
14 |
15 | });
16 |
17 | it('Wrong value', function(done) {
18 |
19 | testWrapper({
20 | value: '123123'
21 | },function (el) {
22 | parseInt(el.result).should.not.equal(4);
23 | }, done);
24 |
25 |
26 | });
27 |
28 | });
--------------------------------------------------------------------------------
/filters/link/link.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.link = function (input, format) {
2 | var a = document.createElement('a');
3 | a.href = input;
4 |
5 | if (format === 'domain') {
6 | parts = a.hostname.split('.');
7 | if (parts[1]) {
8 | return parts.slice(1, parts.length).join('.');
9 | }
10 | } else if (format) {
11 | return a[format];
12 | } else {
13 | return a.host;
14 | }
15 | };
--------------------------------------------------------------------------------
/filters/link/link.test.js:
--------------------------------------------------------------------------------
1 | describe('Link', function () {
2 |
3 | var tmpl = '{{ value | link(format) }}';
4 |
5 | beforeEach(function (done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Default format (host)', function (done) {
11 | testWrapper({
12 | value: 'https://news.layervault.com'
13 | },function (el) {
14 | el.result.should.equal('news.layervault.com');
15 | }, done);
16 | });
17 |
18 | it('Domain format', function (done) {
19 | testWrapper({
20 | value: 'https://news.layervault.com',
21 | format: 'domain'
22 | },function (el) {
23 | el.result.should.equal('layervault.com');
24 | }, done);
25 | });
26 |
27 | it('Pathname', function (done) {
28 | testWrapper({
29 | value: 'https://news.layervault.com/somelink',
30 | format: 'pathname'
31 | },function (el) {
32 | el.result.should.equal('/somelink');
33 | }, done);
34 | });
35 |
36 | });
--------------------------------------------------------------------------------
/filters/lowercase/lowercase.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.lowercase = function (input) {
2 | if (typeof input === "string") {
3 | return input.toLowerCase();
4 | } else {
5 | return input;
6 | }
7 | };
--------------------------------------------------------------------------------
/filters/lowercase/lowercase.test.js:
--------------------------------------------------------------------------------
1 | describe('Lowercase filter', function () {
2 |
3 | var tmpl = '{{ value | lowercase }}';
4 |
5 | beforeEach(function (done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Correct lowercase', function (done) {
11 | testWrapper({
12 | value: 'PUTIN'
13 | },function (el) {
14 | el.result.should.equal('putin');
15 | }, done);
16 | });
17 |
18 | it('Number input', function (done) {
19 | testWrapper({
20 | value: 123
21 | },function (el) {
22 | el.result.should.equal('123');
23 | }, done);
24 | });
25 | });
--------------------------------------------------------------------------------
/filters/replace/replace.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.replace = function (input, oldValue, newValue) {
2 |
3 | if(typeof input === "string") {
4 | return input.replace(oldValue, newValue);
5 | } else {
6 | return input;
7 | }
8 |
9 | };
--------------------------------------------------------------------------------
/filters/replace/replace.test.js:
--------------------------------------------------------------------------------
1 | describe('Lowercase filter', function () {
2 |
3 | var tmpl = '{{ value | replace(oldValue, newValue) }}';
4 |
5 | beforeEach(function (done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Correct String to replace', function (done) {
11 | testWrapper({
12 | value: 'Hello World',
13 | oldValue: 'World',
14 | newValue: 'Folks!'
15 | },function (el) {
16 | el.result.should.equal('Hello Folks!');
17 | }, done);
18 | });
19 |
20 | it('String undefined, not replaced', function (done) {
21 | testWrapper({
22 | value: 'Hello World',
23 | oldValue: 'world',
24 | newValue: 'Folks!'
25 | },function (el) {
26 | el.result.should.equal('Hello World');
27 | }, done);
28 |
29 | });
30 |
31 | it('Input isn\'t string', function (done) {
32 |
33 | testWrapper({
34 | value: 420,
35 | oldValue: 20,
36 | newValue: 1991
37 | },function (el) {
38 | el.result.should.equal('420');
39 | }, done);
40 |
41 | });
42 |
43 | });
--------------------------------------------------------------------------------
/filters/reverse/reverse.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.reverse = function (input) {
2 | return input.split("").reverse().join("");
3 | };
--------------------------------------------------------------------------------
/filters/reverse/reverse.test.js:
--------------------------------------------------------------------------------
1 | describe('Reverse test', function () {
2 |
3 | var tmpl = '{{ value | reverse }}';
4 |
5 | beforeEach(function (done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Correct reverse', function (done) {
11 | testWrapper({
12 | value: 'max'
13 | },function (el) {
14 | el.result.should.equal('xam');
15 | }, done);
16 | });
17 | });
--------------------------------------------------------------------------------
/filters/round/round.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.round = function (input) {
2 | if(!isNaN(Number(input))) {
3 | return Number(input).toFixed(0);
4 | } else {
5 | return input;
6 | }
7 | };
--------------------------------------------------------------------------------
/filters/round/round.test.js:
--------------------------------------------------------------------------------
1 | describe('Round', function () {
2 |
3 | var tmpl = '{{ value | round }}';
4 |
5 | beforeEach(function (done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Number round', function (done) {
11 | testWrapper({
12 | value: 146.123
13 | },function (el) {
14 | el.result.should.equal('146');
15 | }, done);
16 | });
17 |
18 | it('Zero', function (done) {
19 | testWrapper({
20 | value: 0
21 | },function (el) {
22 | el.result.should.equal('0');
23 | }, done);
24 | });
25 |
26 | it('String round', function (done) {
27 | testWrapper({
28 | value: 'test'
29 | },function (el) {
30 | el.result.should.equal('test');
31 | }, done);
32 | });
33 |
34 | });
--------------------------------------------------------------------------------
/filters/trim/trim.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.trim = function (input) {
2 | if(typeof input === 'string') {
3 | return input.trim();
4 | } else {
5 | return input;
6 | }
7 | };
--------------------------------------------------------------------------------
/filters/trim/trim.test.js:
--------------------------------------------------------------------------------
1 | describe('Trim test', function () {
2 |
3 | var tmpl = '{{ value | trim }}';
4 |
5 | beforeEach(function (done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Correct trim', function (done) {
11 | testWrapper({
12 | value: ' string '
13 | },function (el) {
14 | el.result.should.equal('string');
15 | }, done);
16 | });
17 |
18 | it('Incorrect input', function (done) {
19 | testWrapper({
20 | value: 123
21 | },function (el) {
22 | el.result.should.equal('123');
23 | }, done);
24 | });
25 |
26 | });
--------------------------------------------------------------------------------
/filters/uppercase/uppercase.js:
--------------------------------------------------------------------------------
1 | PolymerExpressions.prototype.uppercase = function (input) {
2 | if(typeof input === 'string') {
3 | return input.toUpperCase();
4 | } else {
5 | return input;
6 | }
7 | };
--------------------------------------------------------------------------------
/filters/uppercase/uppercase.test.js:
--------------------------------------------------------------------------------
1 | describe('Uppercase test', function () {
2 |
3 | var tmpl = '{{ value | uppercase }}';
4 |
5 | beforeEach(function (done) {
6 | initTemplate(tmpl);
7 | done();
8 | });
9 |
10 | it('Correct uppercase', function (done) {
11 | testWrapper({
12 | value: 'Max Barinov'
13 | },function (el) {
14 | el.result.should.equal('MAX BARINOV');
15 | }, done);
16 | });
17 |
18 | it('Incorrect input', function (done) {
19 | testWrapper({
20 | value: 123
21 | },function (el) {
22 | el.result.should.equal('123');
23 | }, done);
24 | });
25 |
26 | });
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Polymer expression
6 |
7 |
8 |
9 |
10 |
11 |
12 | Polymer Filters
13 |
14 | A collection of Polymer filters for formatting values of expressions.
15 |
16 |
17 | Length expression
18 | {{ 'test' | length }}
19 |
20 |
21 |
23 | {{ value | length }}
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | "use strict";
3 |
4 | module.exports = function (config) {
5 |
6 | var configuration = {
7 |
8 | // frameworks to use
9 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
10 | frameworks: [
11 | 'mocha',
12 | 'should'
13 | ],
14 |
15 | // list of files / patterns to load in the browser
16 | files: [
17 | 'bower_components/polymer/polymer.js',
18 | 'test/karma-loader.js',
19 |
20 | 'test/test-component.html',
21 |
22 | 'filters/**/*.js',
23 |
24 | 'filters/**/*.spec.html',
25 |
26 | 'filters/**/*.test.js',
27 |
28 | {
29 | pattern: 'bower_components/**/*',
30 | included: false
31 | },
32 | {
33 | pattern: 'filters/**/*',
34 | included: false
35 | },
36 | ],
37 |
38 | preprocessors: {
39 | // source files, that you wanna generate coverage for
40 | // do not include tests or libraries
41 | // (these files will be instrumented by Istanbul)
42 | 'filters/**/*.js': ['coverage']
43 | },
44 |
45 | coverageReporter: {
46 | type: 'lcov',
47 | dir: 'coverage'
48 | },
49 |
50 | // test results reporter to use
51 | // possible values: 'dots', 'progress'
52 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter
53 | reporters: ['progress', 'coverage'],
54 |
55 |
56 | // web server port
57 | port: 9876,
58 |
59 | // enable / disable colors in the output (reporters and logs)
60 | colors: true,
61 |
62 | // level of logging
63 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN ||
64 | // config.LOG_INFO || config.LOG_DEBUG
65 | logLevel: config.LOG_DEBUG,
66 |
67 | // start these browsers
68 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
69 | browsers: ['Chrome'],
70 | customLaunchers: {
71 | Chrome_travis_ci: {
72 | base: 'Chrome',
73 | flags: ['--no-sandbox']
74 | }
75 | },
76 |
77 | // Continuous Integration mode
78 | // if true, Karma captures browsers, runs the tests and exits
79 | singleRun: false
80 |
81 | };
82 |
83 | if (process.env.TRAVIS) {
84 | configuration.browsers = ['Chrome_travis_ci'];
85 | }
86 |
87 | config.set(configuration);
88 | };
89 | }());
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "poly-filters",
3 | "version": "1.0.0",
4 | "description": "Polymer filters",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/mbarinov/poly-filters.git"
8 | },
9 | "main": "karma.conf.js",
10 | "scripts": {
11 | "test": "./node_modules/karma/bin/karma start --single-run"
12 | },
13 | "author": "Maxim Barinov ",
14 | "license": "ISC",
15 | "devDependencies": {
16 | "graceful-fs": "3.0.5",
17 | "karma": "0.12.31",
18 | "karma-chrome-launcher": "0.1.7",
19 | "karma-coverage": "^0.2.7",
20 | "karma-mocha": "0.1.10",
21 | "karma-phantomjs-launcher": "0.1.4",
22 | "karma-should": "0.0.1",
23 | "lcov-filter": "0.0.1",
24 | "mocha": "2.1.0",
25 | "mocha-lcov-reporter": "0.0.1",
26 | "should": "4.6.5"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/poly-filters.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/karma-loader.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | mocha.setup('bdd');
3 |
4 | window.__karma__.loaded = function () {
5 | };
6 |
7 | window.addEventListener('polymer-ready', function run() {
8 | window.__karma__.start();
9 | window.removeEventListener('polymer-ready', run);
10 | });
11 |
12 | window.initTemplate = function (template) {
13 | var wrapper = document.querySelector('#test');
14 |
15 | if (wrapper) {
16 | wrapper.parentNode.removeChild(wrapper);
17 | }
18 |
19 | var el = document.createElement('div');
20 | el.id = 'test';
21 |
22 | el.innerHTML = '' +
23 | template +
24 | '';
25 |
26 | document.body.appendChild(el);
27 |
28 | return el;
29 | };
30 |
31 | window.testWrapper = function (params, cb, done) {
32 | var el = document.querySelector('test-component');
33 |
34 | if(params) {
35 | Object.keys(params).forEach(function (key) {
36 | el[key] = params[key];
37 | });
38 | }
39 |
40 | setTimeout(function() {
41 | cb(el);
42 | done();
43 | }, 100);
44 | };
--------------------------------------------------------------------------------
/test/test-component.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
28 |
--------------------------------------------------------------------------------