Skip to content

Commit

Permalink
Merge pull request #8 from tprzytula/development
Browse files Browse the repository at this point in the history
Refactored client/server unit tests & coverage
  • Loading branch information
tprzytula committed Jun 14, 2018
2 parents f7ba121 + 1c80b8d commit 1970a9e
Show file tree
Hide file tree
Showing 25 changed files with 856 additions and 759 deletions.
8 changes: 6 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"globals": {
"Meteor": true,
"it": true,
"describe": true
"describe": true,
"beforeEach": true,
"afterEach": true
},
"rules": {
"comma-dangle": [
Expand All @@ -34,6 +36,8 @@
"never"
],
"no-underscore-dangle": 0,
"no-console": 0
"no-console": 0,
"one-var-declaration-per-line": 0,
"one-var": 0
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.coverage
node_modules/
npm-debug.log
7 changes: 4 additions & 3 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
[email protected] # Packages every Meteor app needs to have
[email protected] # Packages for a great mobile UX
[email protected] # The database Meteor supports right now
[email protected] # Compile .html files into Meteor Blaze views
[email protected] # Reactive variable for tracker
[email protected] # Compile .html files into Meteor Blaze views
[email protected] # Reactive variable for tracker
[email protected] # Meteor's client-side reactive programming library

[email protected] # CSS minifier run for production mode
[email protected] # JS minifier run for production mode
[email protected] # ECMAScript 5 compatibility for older browsers
[email protected] # Enable ECMAScript2015+ syntax in app code
[email protected] # Enable ECMAScript2015+ syntax in app code
[email protected] # Server-side component of the `meteor shell` command

tprzytula:remember-me
accounts-base
meteortesting:mocha
lmieulet:meteor-coverage
3 changes: 2 additions & 1 deletion .meteorignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package.js
package.js
.coverage
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ appveyor.yml
.travis.yml
node_modules
npm-debug.log
.coverage
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ addons:
before_install:
- "curl -L https://raw.githubusercontent.com/arunoda/travis-ci-meteor-packages/dca8e51fafd60d9e5a8285b07ca34a63f22a5ed4/configure.sh | /bin/sh"
before_script:
- "export PATH=$HOME/.meteor:$PATH"
- "export PATH=$HOME/.meteor:$PATH"
after_success:
- npm run coveralls
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Meteor - Remember Me
# Meteor - Remember Me
[![Build Status](https://travis-ci.org/tprzytula/Meteor-Remember-Me.svg?branch=master)](https://travis-ci.org/tprzytula/Meteor-Remember-Me) [![Coverage Status](https://coveralls.io/repos/github/tprzytula/Meteor-Remember-Me/badge.svg)](https://coveralls.io/github/tprzytula/Meteor-Remember-Me)
### Integrated remember me functionality support for Meteor


Expand Down
1 change: 1 addition & 0 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class RememberMe {
}

/* eslint-disable */
/* istanbul ignore next */
/*
The method is based on the original one in Accounts:
https://github.com/meteor/meteor/blob/46257bad264bf089e35e0fe35494b51fe5849c7b/packages/accounts-password/password_client.js#L33
Expand Down
35 changes: 34 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
"eslint": "eslint ./client ./server ./test || true",
"eslint-check": "eslint ./client ./server ./test",
"eslint-fix": "eslint ./client ./server ./test --fix || true",
"test": "cross-env TEST_BROWSER_DRIVER=chrome meteor test --once --driver-package meteortesting:mocha",
"test-watch": "cross-env WATCH=1 TEST_BROWSER_DRIVER=chrome meteor test --driver-package meteortesting:mocha"
"test": "cross-env TEST_BROWSER_DRIVER=chrome COVERAGE=1 COVERAGE_OUT_LCOVONLY=1 COVERAGE_OUT_HTML=1 COVERAGE_OUT_TEXT_SUMMARY=1 COVERAGE_APP_FOLDER=$PWD/ meteor test --once --driver-package meteortesting:mocha",
"test-watch": "cross-env WATCH=1 TEST_BROWSER_DRIVER=chrome meteor test --driver-package meteortesting:mocha",
"coveralls": "cat .coverage/lcov.info | coveralls"
},
"devDependencies": {
"@babel/runtime": "^7.0.0-beta.44",
"babel-eslint": "^8.2.2",
"bcrypt": "^2.0.0",
"chromedriver": "^2.37.0",
"coveralls": "^3.0.1",
"cross-env": "^5.1.4",
"eslint": "4.18.2",
"eslint-config-airbnb-base": "^12.1.0",
Expand Down
121 changes: 121 additions & 0 deletions test/client/helpers.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
const { exportFlagFromParams, exportCallbackFromParams } = require('./../../client/helpers');
const chai = require('ultimate-chai');

const { expect } = chai;

describe('Given exportFlagFromParams', () => {
const sampleFlag = false;
const sampleMethod = () => {};
let result;

describe('When rememberMe flag is a first param', () => {
beforeEach(() => {
result = exportFlagFromParams([sampleFlag]);
});

it('should return the flag', () => {
expect(result).to.be.equal(sampleFlag);
});
});

describe('When rememberMe flag is a second param', () => {
beforeEach(() => {
result = exportFlagFromParams([sampleMethod, sampleFlag]);
});

it('should return the flag', () => {
expect(result).to.be.equal(sampleFlag);
});
});

describe('When parameters are only containing a method', () => {
beforeEach(() => {
result = exportFlagFromParams([sampleMethod]);
});

it('should return true as default', () => {
expect(result).to.be.equal(true);
});
});

describe('When the parameters are empty', () => {
beforeEach(() => {
result = exportFlagFromParams([]);
});

it('should return true as default', () => {
expect(result).to.be.equal(true);
});
});

describe('When nothing is passed to the method', () => {
beforeEach(() => {
result = exportFlagFromParams();
});

it('should return true as default', () => {
expect(result).to.be.equal(true);
});
});
});

describe('Given exportCallbackFromParams', () => {
const sampleMethod = () => {};
let result;

describe('When function is a first param', () => {
beforeEach(() => {
result = exportCallbackFromParams([sampleMethod, 1, 'abc']);
});

it('should return the same method', () => {
expect(result).to.be.equal(sampleMethod);
});
});

describe('When function is a second param', () => {
beforeEach(() => {
result = exportCallbackFromParams([1, sampleMethod, 'abc']);
});

it('should return a function', () => {
expect(typeof result).to.be.equal('function');
});

describe('And the returned function', () => {
it('should not be the same as the one in params', () => {
expect(result).to.not.be.equal(sampleMethod);
});
});
});

describe('When function is not in parameters', () => {
beforeEach(() => {
result = exportCallbackFromParams([1, 'abc']);
});

it('should return a function', () => {
expect(typeof result).to.be.equal('function');
});
});

describe('When the parameters are empty', () => {
beforeEach(() => {
result = exportCallbackFromParams([]);
});

it('should return a function', () => {
expect(typeof result).to.be.equal('function');
});
});

describe('When nothing is passed to the method', () => {
beforeEach(() => {
result = exportCallbackFromParams();
});

it('should return a function', () => {
expect(typeof result).to.be.equal('function');
});
});
});
Loading

0 comments on commit 1970a9e

Please sign in to comment.