Skip to content

Commit

Permalink
set up mocha/expectjs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoow committed Feb 27, 2014
1 parent 9d1c3e7 commit 714f2c7
Show file tree
Hide file tree
Showing 18 changed files with 7,421 additions and 22 deletions.
10 changes: 6 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function(grunt) {
'jshint',
'build_tests',
'connect:dev',
'qunit'
'mocha'
]);

this.registerTask('docs', 'Builds the documentation', [
Expand Down Expand Up @@ -191,9 +191,11 @@ module.exports = function(grunt) {

clean: ['dist', 'tmp', 'docs/build'],

qunit: {
all: {
mocha: {
test: {
options: {
run: true,
reporter: 'Spec',
urls: function() {
var bundle = process.env.BUNDLE || '';
return [
Expand Down Expand Up @@ -231,7 +233,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-es6-module-transpiler');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"grunt-cli": "~0.1.11",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-qunit": "~0.3.0",
"grunt-mocha": "~0.4.10",
"grunt-es6-module-transpiler": "~0.6.0",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-jshint": "~0.8.0",
Expand Down
17 changes: 12 additions & 5 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@
<head>
<meta charset="utf-8">
<title>EmberSimpleAuth tests</title>
<link rel="stylesheet" href="vendor/qunit.css">
<link rel="stylesheet" href="vendor/mocha.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="vendor/qunit.js"></script>
<script src="../vendor/loader.js"></script>
<div id="mocha"></div>
<script src="lib/dependencies_loader.js"></script>
<script src="vendor/expect.js"></script>
<script src="vendor/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="../vendor/loader.js"></script>
<script src="../tmp/ember-simple-auth.amd.js"></script>
<script src="../tmp/ember-simple-auth-tests.amd.js"></script>
<script type="text/javascript">
Ember.Logger.warn = Ember.K;
for (var key in requireModule.registry) {
if (/^tests\//.test(key)) requireModule(key);
}

mocha.checkLeaks();
mocha.globals(['jQuery']);
if (navigator.userAgent.indexOf('PhantomJS') < 0) {
mocha.run();
}
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion test/tests/authenticators/base_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Base } from 'ember-simple-auth/authenticators/base';
/*import { Base } from 'ember-simple-auth/authenticators/base';
var authenticator;
Expand Down Expand Up @@ -29,3 +29,4 @@ test('invalidates the session', function() {
ok(resolved, 'Authenticators.Base returns a resolving promise for session invalidation.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/authenticators/oauth2_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OAuth2 } from 'ember-simple-auth/authenticators/oauth2';
/*import { OAuth2 } from 'ember-simple-auth/authenticators/oauth2';
var authenticator;
Expand Down Expand Up @@ -148,3 +148,4 @@ test('keeps the token fresh', function() {
ok(!Ember.isEmpty(authenticator._refreshTokenTimeout), 'Authenticators.OAuth2 schedules another refresh when it successfully refreshed the access token.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/authorizers/oauth2_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OAuth2 } from 'ember-simple-auth/authorizers/oauth2';
/*import { OAuth2 } from 'ember-simple-auth/authorizers/oauth2';
var authorizer;
Expand Down Expand Up @@ -32,3 +32,4 @@ test('authorizes an AJAX request', function() {
authorizer.authorize(xhrMock, {});
equal(xhrMock.requestHeaders.Authorization, 'Bearer ' + token, 'Authorizers.OAuth2 adds the access_token to an AJAX request when it is not empty.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/core_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setup, Configuration } from 'ember-simple-auth/core';
/*import { setup, Configuration } from 'ember-simple-auth/core';
import { Session } from 'ember-simple-auth/session';
import { Authenticators } from 'ember-simple-auth/authenticators';
import { Stores } from 'ember-simple-auth/stores';
Expand Down Expand Up @@ -131,3 +131,4 @@ test('registers an AJAX prefilter that authorizes requests', function() {
ajaxPrefilterMock.registeredAjaxPrefilter({ url: 'http://a.different.domain:80' }, {}, {});
ok(authorizerMock.authorized, 'setup registers an AJAX prefilter that authorizes cross-origin requests when the origin is in the crossOriginWhitelist where default ports can be left out.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/mixins/application_route_mixin_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApplicationRouteMixin } from 'ember-simple-auth/mixins/application_route_mixin';
/*import { ApplicationRouteMixin } from 'ember-simple-auth/mixins/application_route_mixin';
import { Configuration } from 'ember-simple-auth/core';
import { Session } from 'ember-simple-auth/session';
import { Ephemeral } from 'ember-simple-auth/stores/ephemeral';
Expand Down Expand Up @@ -146,3 +146,4 @@ test('invalidates the session when an authorization error occurs', function() {
equal(testRoute.get('session.isAuthenticated'), false, 'ApplicationRouteMixin invalidates the current session when an authorization error occurs.');
equal(testRoute.transitionedTo, Configuration.routeAfterInvalidation, 'ApplicationRouteMixin transitions to the routeAfterInvalidation when an authorization error occurs.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/mixins/authenticated_route_mixin_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthenticatedRouteMixin } from 'ember-simple-auth/mixins/authenticated_route_mixin';
/*import { AuthenticatedRouteMixin } from 'ember-simple-auth/mixins/authenticated_route_mixin';
import { Session } from 'ember-simple-auth/session';
import { Ephemeral } from 'ember-simple-auth/stores/ephemeral';
Expand Down Expand Up @@ -64,3 +64,4 @@ test('aborts the attempted transaction when the session is not authenticated', f
ok(!attemptedTransitionMock.aborted, 'AuthenticatedRouteMixin does not abort the attempted transition in beforeModel when the session is authenticated.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/mixins/authentication_controller_mixin_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthenticationControllerMixin } from 'ember-simple-auth/mixins/authentication_controller_mixin';
/*import { AuthenticationControllerMixin } from 'ember-simple-auth/mixins/authentication_controller_mixin';
var AuthenticatorMock = Ember.Object.extend();
Expand Down Expand Up @@ -49,3 +49,4 @@ test('authenticates the session', function() {
deepEqual(sessionMock.invokedAuthenticateWith.options, { 'key': 'value' }, 'AuthenticationControllerMixin authenticates the session with the correct options.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/mixins/login_controller_mixin_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LoginControllerMixin } from 'ember-simple-auth/mixins/login_controller_mixin';
/*import { LoginControllerMixin } from 'ember-simple-auth/mixins/login_controller_mixin';
var testController;
var TestController = Ember.Controller.extend(LoginControllerMixin, {
Expand Down Expand Up @@ -65,3 +65,4 @@ test('does not authenticate the session when identification or password are empt
ok(!sessionMock.invokedAuthenticate, 'LoginControllerMixin does not authenticate the session when authentication is triggered but identification and password are empty.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/session_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Session } from 'ember-simple-auth/session';
/*import { Session } from 'ember-simple-auth/session';
import { Ephemeral } from 'ember-simple-auth/stores/ephemeral';
var session;
Expand Down Expand Up @@ -260,3 +260,4 @@ test('observes changes in the store', function() {
equal(session.get('authenticatorFactory'), 'authenticators:test2', 'Ember.Session updates the authenticator type when the store triggers the "ember-simple-auth:session-updated" event and the authenticator resolves.');
ok(triggeredAuthentication, 'Session triggers the "ember-simple-auth:session-authentication-succeeded" event when the store triggers the "ember-simple-auth:session-updated" event and the authenticator resolves.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/stores/cookie_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cookie } from 'ember-simple-auth/stores/cookie';
/*import { Cookie } from 'ember-simple-auth/stores/cookie';
var store;
Expand Down Expand Up @@ -67,3 +67,4 @@ test('recognizes when the cookies change', function() {
ok(!triggered, 'Ember.SimpleAuth.Stores.Cookie does not trigger the "ember-simple-auth:session-updated" event when no cookies actually changed.');
});
*/
15 changes: 14 additions & 1 deletion test/tests/stores/ephemeral_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import { Ephemeral } from 'ember-simple-auth/stores/ephemeral';

var store;
describe('Stores.Ephemeral', function() {
var store = Ephemeral.create();

it('clears itself', function() {
store.persist({ key1: 'value1', key2: 'value2' });
store.clear();

expect(store.restore().key1).to.be(undefined);
expect(store.restore().key2).to.be(undefined);
});
});

/*var store;
module('Stores.Ephemeral', {
setup: function() {
Expand Down Expand Up @@ -36,3 +48,4 @@ test('saves properties', function() {
equal(store.restore().key2, 'value2', 'Ember.SimpleAuth.Stores.Ephemeral saves multiple properties.');
equal(store.restore().key, 'value', 'Ember.SimpleAuth.Stores.Ephemeral does not destroy previously stored properties when it saves others.');
});
*/
3 changes: 2 additions & 1 deletion test/tests/stores/local_storage_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LocalStorage } from 'ember-simple-auth/stores/local_storage';
/*import { LocalStorage } from 'ember-simple-auth/stores/local_storage';
var store;
Expand Down Expand Up @@ -35,3 +35,4 @@ test('saves properties', function() {
equal(store.restore().key2, 'value2', 'Ember.SimpleAuth.Stores.LocalStorage saves multiple properties.');
equal(store.restore().key, 'value', 'Ember.SimpleAuth.Stores.LocalStorage does not destroy previously stored properties when it saves others.');
});
*/
Loading

0 comments on commit 714f2c7

Please sign in to comment.