Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove tests

  • Loading branch information...
commit cbceb6a3807340e7dc9b93666382aaac548b14ac 1 parent 5e7664a
@mbreton mbreton authored
Showing with 2 additions and 10,493 deletions.
  1. +0 −15 Gruntfile.js
  2. +1 −18 README.md
  3. +0 −41 conf/karma.commons.conf.js
  4. +0 −12 conf/karma.integration.conf.js
  5. +0 −11 conf/karma.unit.conf.js
  6. +1 −5 package.json
  7. +0 −55 tests/integration/tests-integration-utils.js
  8. +0 −66 tests/integration/users/users.test.js
  9. +0 −3,996 tests/libs/chai.js
  10. +0 −157 tests/libs/ember-mocha-adapter.js
  11. +0 −5,339 tests/libs/mocha.js
  12. +0 −16 tests/tests-utils.js
  13. +0 −79 tests/unit/controllers/UserEditController.test.js
  14. +0 −62 tests/unit/controllers/userController.test.js
  15. +0 −54 tests/unit/controllers/usersCreateController.test.js
  16. +0 −57 tests/unit/helpers/helper.test.js
  17. +0 −74 tests/unit/routes/ApplicationRoute.test.js
  18. +0 −21 tests/unit/routes/IndexRoute.test.js
  19. +0 −21 tests/unit/routes/MissingRoute.test.js
  20. +0 −48 tests/unit/routes/UserCreateAndEditRoute.test.js
  21. +0 −66 tests/unit/routes/UserRoute.test.js
  22. +0 −53 tests/unit/routes/UsersCreateRoute.test.js
  23. +0 −57 tests/unit/routes/UsersRoute.test.js
  24. +0 −63 tests/unit/routes/userEditRoute.test.js
  25. +0 −48 tests/unit/views/ModalView.test.js
  26. +0 −59 tests/unit/views/confirmDeleteButtonView.test.js
View
15 Gruntfile.js
@@ -55,20 +55,6 @@ module.exports = function(grunt) {
concat: {
files: ['assets/js/**/*.js', '!assets/js/app.js', '!assets/js/libs.js', '!assets/js/templates.js'],
tasks: ['concat']
- }/*,
- karma: {
- files: ['assets/js/app.js','tests/unit/** /*'],
- tasks: ['karma:unit:run']
- }*/
- },
-
- karma: {
- unit: {
- configFile: 'conf/karma.unit.conf.js',
- background: true
- },
- integration: {
- configFile: 'conf/karma.integration.conf.js'
}
}
@@ -78,7 +64,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-ember-templates');
- grunt.loadNpmTasks('grunt-karma');
// Default task(s).
grunt.registerTask('default', ['sass', 'concat', 'emberTemplates']);
View
19 README.md
@@ -3,7 +3,6 @@ This repository is an Ember 1.0.0 + Ember Data 1.0.0-beta3 simple demo demonstra
* a `Creation` / `Read` / `Update` / `Delete` of a collection of `users`
* complex CSS transitions / animations on `views`
* Handlebars templates precompiling with [Grunt](http://gruntjs.com/getting-started)
-* test suite with [Karma](https://github.com/karma-runner/karma)
* fully responsive version (with touch events, and with animations between routes)
@@ -26,10 +25,6 @@ This command will install locally the following node modules
* [grunt-contrib-concat](https://npmjs.org/package/grunt-contrib-concat)
* [grunt-contrib-watch](https://npmjs.org/package/grunt-contrib-watch)
* [grunt-ember-templates](https://npmjs.org/package/grunt-ember-templates)
-* [grunt-karma](https://npmjs.org/package/grunt-karma)
-* [karma-mocha](https://npmjs.org/package/karma-mocha)
-* [karma-coverage](https://npmjs.org/package/karma-coverage)
-* [karma-coffee-preprocessor](https://npmjs.org/package/karma-coffee-preprocessor)
### How to compile css
@@ -47,16 +42,4 @@ Run the following command:
### How to concatenate js files
Run the following command:
-`grunt watch` or `grunt concat`
-
-### How to run tests
-
-**Requirements:**
-You need [Karma](https://github.com/karma-runner/karma) on your machine
-`sudo npm install -g karma`
-
-Then run the following command:
-`karma start tests/conf/karma.unit.conf.js`
-
-If you don't want to install Karma on your system you could simply use the `bin` located in the `node_modules/`. So you could run the same command as above but like this:
-`./node_modules/karma/bin/karma start conf/karma.unit.conf.js`
+`grunt watch` or `grunt concat`
View
41 conf/karma.commons.conf.js
@@ -1,41 +0,0 @@
-module.exports = function (config){
- config.set({
- plugins: [
- 'karma-mocha',
- 'karma-chrome-launcher',
- 'karma-phantomjs-launcher',
- 'karma-firefox-launcher',
- "karma-coverage",
- "karma-coffee-preprocessor"
- ],
-
- files: [
- // Source
- 'assets/js/libs.js',
- 'assets/js/templates.js',
- 'assets/js/app.js',
-
- // Tests
- 'tests/libs/**/*.js',
- 'tests/tests-utils.js'
- ],
-
- preprocessors: {
- '**/*.coffee': 'coffee',
- 'assets/js/app.js': 'coverage'
- },
-
- reporters: ['progress', 'coverage'],
- basePath: '../',
- frameworks: ['mocha'],
- exclude: [],
- port: 9876,
- colors: true,
- logLevel: config.LOG_INFO,
- autoWatch: true,
- browsers: ['PhantomJS'],
- captureTimeout: 20000,
- singleRun: false,
- reportSlowerThan: 500
- });
-};
View
12 conf/karma.integration.conf.js
@@ -1,12 +0,0 @@
-module.exports = function(config) {
- require(__dirname + '/karma.commons.conf')(config);
-
- config.set({
- files : config.files.concat('tests/integration/**/*.js'),
- reportSlowerThan: 2000,
- coverageReporter: {
- type : 'html',
- dir : 'tests/coverage/integration'
- }
- });
-};
View
11 conf/karma.unit.conf.js
@@ -1,11 +0,0 @@
-module.exports = function(config) {
- require(__dirname + '/karma.commons.conf')(config);
-
- config.set({
- files : config.files.concat('tests/unit/**/*.js'),
- coverageReporter: {
- type : 'html',
- dir : 'tests/coverage/unit'
- }
- });
-};
View
6 package.json
@@ -8,10 +8,6 @@
"grunt-contrib-watch": "~0.4.4",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-sass": "~0.4.1",
- "grunt-ember-templates": "*",
- "grunt-karma": "*",
- "karma-mocha": "~0.1",
- "karma-coverage": "~0.1",
- "karma-coffee-preprocessor": "~0.1"
+ "grunt-ember-templates": "*"
}
}
View
55 tests/integration/tests-integration-utils.js
@@ -1,55 +0,0 @@
-Ember.Test.registerHelper('waitFor', function (app, testFx, onReady, onTimeout, timeOutMillis) {
- var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3000; //< Default Max Timout is 3s
- var start = new Date().getTime();
- var condition = false;
-
- Em.run.begin();
- var interval = setInterval(function() {
- if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
- // If not time-out yet and condition not yet fulfilled
- condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
- } else {
- if(!condition) {
- // If condition still not fulfilled (timeout but condition is 'false')
- typeof(onTimeout) === "string" ? eval(onTimeout) : onTimeout(); //< Do what it's supposed to do once the condition is fulfilled
- } else {
- // Condition fulfilled (timeout and/or condition is 'true')
- console.log("'waitFor()' finished in " + (new Date().getTime() - start) + "ms.");
- typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
- }
- clearInterval(interval);
- Em.run.end();
- }
- }, 250); //< repeat check every 250ms
-
- return wait(app);
-});
-
-// inject many helpers usefull for the integration tests
-App.injectTestHelpers();
-
-App.Store = DS.Store.extend({
- adapter: 'DS.FixtureAdapter'
-});
-
-// Global Integration tests beforeEach
-beforeEach(function(){
- // run application initialization
- App.User.FIXTURES = [
- {
- id: 1,
- name: 'Julien Knebel',
- email: 'julienknebel@gmail.com',
- bio: 'Freelance web & print designer + front-end developer',
- avatarUrl: './assets/images/avatars/jk.jpg',
- creationDate: 'Fri Aug 09 2013 15:13:16 GMT+0200 (CEST)'
- }
- ];
- Ember.run(App, App.advanceReadiness);
-});
-
-// Global Integrations tests afterEach
-afterEach(function(){
- // reset the application state after each test
- Ember.run(App, App.reset);
-});
View
66 tests/integration/users/users.test.js
@@ -1,66 +0,0 @@
-describe('Users', function () {
-
- it('User creation', function () {
- visit('/users/create') // go to form for new user
- .fillIn('.user-edit.pane input:eq(0)', 'MatAvatar') // then... Fill "MatAvatar" into the first field
- .fillIn('.user-edit.pane input:eq(1)', 'MatBreton') // then... Fill "MatBreton" into this second field
- .fillIn('.user-edit.pane input:eq(2)', 'mbreton@xebia.fr') // then... Fill "mbreton@xebia.fr" into this third field
- .fillIn('.user-edit.pane textarea', 'My short intro') // then... Fill "My short bio" into the last field
- .click('.user-edit.pane .aright button.btn-desktop') // then ... Click on the validation button
- .then(function () { // then, the application should redirect us to the user card index ...
- // we asssert that we have all informations filled in the fields
- $('.user-profile.pane h2').text().should.be.equal('MatBreton');
- $('.user-profile.pane address').text().should.be.equal('mbreton@xebia.fr');
- $('.user-profile.pane img').attr('src').should.be.equal('MatAvatar');
- $('.user-profile.pane .bio').text().should.be.equal('My short intro');
- });
- });
-
- it('User consultation', function () {
- visit('/users') // go to the list of user
- .click('ul.users-listing li a:eq(0)').then(function () { // then ... click on the first user in the list
- // check if its index card is not empty
- $('.user-profile h2').text().should.not.be.empty;
- $('.user-profile address').text().should.not.be.empty;
- $('.user-profile p.bio').text().should.not.be.empty;
- });
- });
-
-
- it('User deleting', function () {
- visit('/users/1') // go to the user with id 1
- .then(function () {
- // count the number of user in the list
- var nbUser = $('.users-listing li a').length;
-
- // when we are in a then callback we need to return the
- // value of click to chain the calls
- return click('button.icon-trashcan.red')// then ... click on the delete button
- .click('.confirm-box.confirmin button:eq(0)')// then ... click on the confirmation button
- .then(function(){
- // re-count the number of user in the list
- var newNbUser = $('.users-listing li a').length;
- // check that there is one user less
- (nbUser - newNbUser).should.be.equal(1);
- });
- });
- });
-
-
- it('User editing', function () {
- visit('/users/1') // go to the user with id 1
- .click('.user-profile .tools .icon-pencil')// then ... click on edit button
- .fillIn('.user-edit input:eq(0)', "expected_img")// then ... update field one by one
- .fillIn('.user-edit input:eq(1)', "expected_name")
- .fillIn('.user-edit input:eq(2)', "expected_mail")
- .fillIn('.user-edit textarea', "expected_bio")
- .click('.user-edit button')// then ... click on the validation button
- .click('ul.users-listing li a:eq(0)').then(function () { // then ...
- // check that all fields are updated
- $('.user-profile img').attr('src').should.equal('expected_img')
- $('.user-profile h2').text().should.equal("expected_name");
- $('.user-profile address').text().should.equal("expected_mail");
- $('.user-profile p.bio').text().should.equal("expected_bio");
- });
- });
-});
View
3,996 tests/libs/chai.js
0 additions, 3,996 deletions not shown
View
157 tests/libs/ember-mocha-adapter.js
@@ -1,157 +0,0 @@
-(function() {
- var done, doneTimeout, countAsync, emberBdd;
-
- done = null;
- doneTimeout = null;
- isAsync = false;
-
- Ember.Test.MochaAdapter = Ember.Test.Adapter.extend({
- init: function() {
- this._super();
- window.Mocha.interfaces['ember-bdd'] = emberBdd;
- window.mocha.ui('ember-bdd');
- },
- asyncStart: function() {
- isAsync = true;
- clearTimeout(doneTimeout);
- },
- asyncEnd: function() {
- isAsync = false;
- if (done) {
- doneTimeout = setTimeout(function() {
- var d = done;
- done = null;
- d();
- });
- }
- },
- exception: function(reason) {
- var error, d;
-
- error = new Error(reason);
- if (done) {
- d = done;
- done = null;
- d(error);
- } else {
- setTimeout(function() {
- throw error;
- });
- }
- }
- });
-
-
- function fixAsync(suites, methodName) {
- return function(fn) {
- if (fn.length === 1) {
- suites[0][methodName](fn);
- } else {
- suites[0][methodName](function(d) {
- invoke(this, fn, d);
- });
- }
- };
- }
-
- function invoke(context, fn, d) {
- done = d;
- fn.call(context);
- if (!isAsync) {
- done = null;
- d();
- }
- }
-
-
- /**
- ember-bdd mocha interface.
- This interface allows
- the Ember.js tester
- to forget about sync / async
- and treat all tests the same.
-
- This interface, along with the adapter
- will take care of handling sync vs async
- */
-
- emberBdd = function(suite) {
- var suites = [suite];
-
- suite.on('pre-require', function(context, file, mocha) {
-
- context.before = fixAsync(suites, 'beforeAll');
-
- context.after = fixAsync(suites, 'afterAll');
-
- context.beforeEach = fixAsync(suites, 'beforeEach');
-
- context.afterEach = fixAsync(suites, 'afterEach');
-
-
- context.it = context.specify = function(title, fn){
- var suite = suites[0], test;
- if (suite.pending) {
- fn = null;
- }
- if (!fn || fn.length === 1) {
- test = new Mocha.Test(title, fn);
- } else {
- var method = function(d) {
- invoke(this, fn, d);
- };
- method.toString = function() {
- return fn.toString();
- }
- test = new Mocha.Test(title, method);
- }
- suite.addTest(test);
- return test;
- };
-
- context.describe = context.context = function(title, fn){
- var suite = Mocha.Suite.create(suites[0], title);
- suites.unshift(suite);
- fn.call(suite);
- suites.shift();
- return suite;
- };
-
- context.xdescribe =
- context.xcontext =
- context.describe.skip = function(title, fn){
- var suite = Mocha.Suite.create(suites[0], title);
- suite.pending = true;
- suites.unshift(suite);
- fn.call(suite);
- suites.shift();
- };
-
- context.describe.only = function(title, fn){
- var suite = context.describe(title, fn);
- mocha.grep(suite.fullTitle());
- };
-
-
- context.it.only = function(title, fn){
- var test = context.it(title, fn);
- mocha.grep(test.fullTitle());
- };
-
-
- context.xit =
- context.xspecify =
- context.it.skip = function(title){
- context.it(title);
- };
-
-
- });
-
- };
-
-
-}());
-
-// define Mocha adpater
-Ember.Test.adapter = Ember.Test.MochaAdapter.create();
View
5,339 tests/libs/mocha.js
0 additions, 5,339 deletions not shown
View
16 tests/tests-utils.js
@@ -1,16 +0,0 @@
-// declare assertion tools
-var should = chai.should();
-var expect = chai.expect;
-var assert = chai.assert;
-
-// defer ember App initialisation, set router location to none
-App.setupForTesting();
-
-// Global beforeEach
-beforeEach(function(){
-});
-
-// Global afterEach
-afterEach(function(){
-});
-
View
79 tests/unit/controllers/UserEditController.test.js
@@ -1,79 +0,0 @@
-describe ('UserEditController', function(){
-
- // the common instance of UserEditController
- var userEditCtrl = null;
-
- // the common instance of UserController
- var userCtrl = null;
-
- // container of injection of dependencies
- var container = null;
-
- // before each test
- beforeEach(function(){
- // we create a new container to isolate the unit test
- container = new Em.Container ();
-
- // we register a faked UserController because of the 'needs'
- // which define a dependency to this controller
- container.register("controller:user", Em.Object);
-
- // we register the real UserEditController who will tested
- container.register("controller:userEdit", App.UserEditController);
-
- // we retrieves the userController instance
- userCtrl = container.lookup("controller:user");
-
- // we retrieves the UserEditController instance. You're probably wondering,
- // why not just create an instance of UserEditController by
- // calling create method. It's simply because if we had create like
- // that the controller, the 'needs' property was not respected, and the
- // UserController instance injected.
- userEditCtrl = container.lookup("controller:userEdit");
- });
-
- // purge all commons objects
- afterEach(function(){
- userCtrl = userEditCtrl = container = null;
- });
-
- it('closeEditing should set to false editMode and transition to user', function (){
- // counter to check the number of call of each method
- var transitionToRouteCall = 0,
- commitCall =0;
-
- // userCtrl initialization
- userCtrl.set('editMode', true);
-
- // userEditCtrl initialization
- userEditCtrl.setProperties({
- // the 'target' property represent the router instance for a controller
- target: {
- // we mock the transitionToRoute method of the router
- transitionToRoute:function(route){
- // we check if the targeted route by the transition
- // is the 'user' route
- route.should.equal('user');
- // we increment the number of call of the transitionToRoute
- transitionToRouteCall++;
- }
- },
- // the 'store' property represent the 'store' instance of the Ember application
- store: {
- // we mock the commit to count the number of call
- commit:function(){
- commitCall++;
- }
- }
- });
-
- // Call the tested method
- userEditCtrl.save();
-
- // check the number the number of call of each method
- commitCall.should.equal(1);
- transitionToRouteCall.should.equal(1);
- });
-
-
-});
View
62 tests/unit/controllers/userController.test.js
@@ -1,62 +0,0 @@
-describe ('UserController', function(){
- var userCtrl = null;
-
- beforeEach(function(){
- userCtrl = App.UserController.create();
- });
-
- it('delete should toggle deleteMode property', function (){
- userCtrl.get('deleteMode').should.be.false;
- userCtrl.delete();
- userCtrl.get('deleteMode').should.be.true;
- userCtrl.delete();
- userCtrl.get('deleteMode').should.be.false;
- });
-
- it('cancelDelete should set deleteMode property to false', function (){
- userCtrl.set('deleteMode', true);
- userCtrl.cancelDelete();
- userCtrl.get('deleteMode').should.be.false;
- });
-
- it('confirmDelete should delete record and transition to users', function (){
- var deleteRecordCall = 0;
- var transitionToRouteCall = 0;
- var commitCall = 0;
-
- userCtrl.setProperties({
- content:{
- deleteRecord:function(){ deleteRecordCall++; }
- },
- store: {
- commit:function(){commitCall++;}
- },
- target:{
- transitionToRoute:function(route) {
- route.should.equal('users');
- transitionToRouteCall++;
- }
- }
- });
- userCtrl.confirmDelete();
- deleteRecordCall.should.equal(1);
- transitionToRouteCall.should.equal(1);
- commitCall.should.equal(1);
- });
-
- it('edit should set deleteMode to false and editMode to true then transition to user.edit', function (){
- var transitionToRouteCall = 0;
- userCtrl.setProperties({
- target:{
- transitionToRoute:function(route) {
- route.should.equal('user.edit');
- transitionToRouteCall++;
- }
- }
- });
- userCtrl.edit();
- userCtrl.get('deleteMode').should.be.false;
- userCtrl.get('editMode').should.be.true;
- transitionToRouteCall.should.equal(1);
- });
-});
View
54 tests/unit/controllers/usersCreateController.test.js
@@ -1,54 +0,0 @@
-describe ('UsersCreateController', function(){
- var usersCreateCtrl = null;
- var oldUserClass;
-
- beforeEach(function(){
- oldUserClass = App.User;
- var container = new Em.Container ();
- container.register("controller:usersCreate", App.UsersCreateController);
- container.register("controller:user", Em.Object);
- usersCreateCtrl = container.lookup("controller:usersCreate");
- });
-
- afterEach(function(){
- App.User = oldUserClass;
- });
-
- it('addUser should createRecord and transition to user', function (){
- var transitionToRouteCall = 0;
- var createRecordCall = 0;
- var commitCall = 0;
-
- var content = Em.Object.create({
- id:"Content's UsersCreateController",
- creationDate:null
- });
- App.User = {
- createRecord:function(user){
- user.should.be.equal(content);
- createRecordCall++;
- }
- };
-
- usersCreateCtrl.setProperties({
- target: {
- transitionToRoute:function(route, model){
- route.should.equal('user');
- model.should.equal(model);
- transitionToRouteCall++;
- }
- },
- content : content,
- store : {
- commit:function(){
- commitCall++;
- }
- }
- });
- usersCreateCtrl.save();
-
- transitionToRouteCall.should.equal(1);
- createRecordCall.should.equal(1);
- commitCall.should.equal(1);
- });
-});
View
57 tests/unit/helpers/helper.test.js
@@ -1,57 +0,0 @@
-describe('Helpers', function () {
-
- // a view instance who will serve of container
- var view;
-
- // a simple method helper to append synchronously a view in the dom
- var appendView = function (view) {
- Ember.run(function () {
- view.appendTo('#helpers-fixture');
- });
- };
-
- // before the test suite we create a dom element to sandbox our dom experiment
- before(function () {
- $('<div id="helpers-fixture"></div>').appendTo($('body'));
- });
-
- // after the test suite we removed it
- after(function () {
- $('#helpers-fixture').remove();
- });
-
- // after each test, if the view exist we destroy it
- afterEach(function () {
- Em.run(function () {
- if (view) {
- view.destroy();
- }
- });
- });
-
-
- it('formatDate should return a relative date from now', function () {
-
- // the first step is to create the container view. This view will
- // contains a fake controller with specific dates. We define in the
- // same time a template of the fly containing few uses of "formatDate"
- // with specifics dates.
- view = Em.View.create({
- controller: Em.Object.create({
- aYear: new moment().subtract('years', 1),
- threeMonths: new moment().subtract('months', 3),
- tenDays: new moment().subtract('days', 10)
- }),
- template: Em.Handlebars.compile("{{formatDate aYear}}|" + //
- "{{formatDate threeMonths}}|" + //
- "{{formatDate tenDays}}")
- });
- // the second step : it's to append the view in the DOM
- appendView(view);
-
- // And finally : we can check here the HTML resulting and
- // verify that the helper have the expected behaviour
- view.$().text().should.equal('a year ago|3 months ago|10 days ago');
- // Note : text method here, is a JQuery method
- });
-});
View
74 tests/unit/routes/ApplicationRoute.test.js
@@ -1,74 +0,0 @@
-describe('ApplicationRoute', function () {
-
- // common ApplicationRoute instance
- var appRoute;
-
- // container of injection of dependencies
- var container;
-
- // before each unit test
- beforeEach(function () {
-
- // we create a new container to isolate the unit test
- container = new Em.Container();
-
- // instantiation by passing it the container previously created in two
- // locations. The first in the route itself and the second in the router.
- // we need too to mock the 'router' instance with a blank object
- appRoute = App.ApplicationRoute.create({
- router: {
- container: container,
- router: {}
- },
- container: container
- });
- });
-
- // after each unit test
- afterEach(function () {
- // deleting all objects created for the test, to reset state
- container = appRoute = null;
- });
-
- it('goBack event should transitionTo users',function(){
- var transitionToRouteCall =0;
-
- // a few dirty, but no idea to how to unit test by another manner
- appRoute.events.transitionTo = function(route){
- // we check if the targeted route by the transition
- // is the 'user' route
- route.should.be.equal('users');
- // we increment the number of call of the transitionToRoute
- transitionToRouteCall++;
- }
- appRoute.events.goBack();
-
- // checking ...
- transitionToRouteCall.should.be.equal(1);
- });
-
-
- it('goBack event should should set true to modalVisible to a named controller',function(){
- var controllerForCall =0;
-
- // create a fake who will return by the mocked controllerFor method
- var fakeCtrl = Em.Object.create({
- modalVisible : false
- });
-
- // a few dirty, but no idea to how to unit test by another manner
- appRoute.events.controllerFor = function(controllerName){
- // we check if the targeted route by the transition
- // is the 'user' route
- controllerName.should.be.equal('aCtrl');
- // we increment the number of call of the transitionToRoute
- controllerForCall++;
- return fakeCtrl;
- };
- appRoute.events.showModal('aCtrl');
-
- // checking ...
- controllerForCall.should.be.equal(1);
- fakeCtrl.modalVisible.should.be.true;
- });
-});
View
21 tests/unit/routes/IndexRoute.test.js
@@ -1,21 +0,0 @@
-describe('IndexRoute',function(){
-
- it('should redirect to users route directly',function (){
- // to count the number of call of transitionToCall
- var transitionToCall = 0;
-
- // create an instance of IndexRoute
- var indexRoute = App.IndexRoute.create({
- // mock transitionTo to check the passed route
- // and count the number of call
- transitionTo:function(route){
- transitionToCall++;
- route.should.be.equal("users");
- }
- });
- indexRoute.redirect();
-
- // verify that transition has been called once
- transitionToCall.should.be.equal(1);
- });
-})
View
21 tests/unit/routes/MissingRoute.test.js
@@ -1,21 +0,0 @@
-describe('MissingRoute',function(){
-
- it('should redirect to users route directly',function (){
- // to count the number of call of transitionToCall
- var transitionToCall = 0;
-
- // create an instance of MissingRoute
- var missingRoute = App.MissingRoute.create({
- // mock transitionTo to check the passed route
- // and count the number of call
- transitionTo:function(route){
- transitionToCall++;
- route.should.be.equal("users.index");
- }
- });
- missingRoute.redirect();
-
- // verify that transition has been called once
- transitionToCall.should.be.equal(1);
- });
-})
View
48 tests/unit/routes/UserCreateAndEditRoute.test.js
@@ -1,48 +0,0 @@
-describe('AUserFormRoute',function(){
- var userCtrl;
- var userEditRoute;
-
- beforeEach(function(){
- var container = new Em.Container();
-
- container.register("controller:user", Em.Object.extend({
- editMode: undefined,
- deleteMode: undefined
- }));
-
- userEditRoute = App.UserCreateAndEditRoute.create({
- router : {
- container:container,
- router:{}
- },
- container:container
- });
-
- userCtrl = container.lookup('controller:user');
- });
-
- afterEach(function(){
- userEditRoute = userCtrl = null;
- });
-
- it('activate should change value of editMode and deletedMode',function(){
-
- userCtrl.setProperties({
- editMode: false,
- deleteMode: true
- });
- userEditRoute.activate();
- userCtrl.get('editMode').should.be.true;
- userCtrl.get('deleteMode').should.be.false;
- });
-
- it('desactivate should change value of editMode and deleteMode',function(){
- userCtrl.setProperties({
- editMode: true,
- deleteMode: true
- });
- userEditRoute.deactivate();
- userCtrl.get('editMode').should.be.false;
- userCtrl.get('deleteMode').should.be.false;
- })
-});
View
66 tests/unit/routes/UserRoute.test.js
@@ -1,66 +0,0 @@
-describe('UserRoute', function () {
-
- // common UserRoute instance
- var userRoute;
-
- // container of injection of dependencies
- var container;
-
- // before each unit test
- beforeEach(function () {
-
- // we create a new container to isolate the unit test
- container = new Em.Container();
-
- // instantiation by passing it the container previously created in two
- // locations. The first in the route itself and the second in the router.
- // we need too to mock the 'router' instance with a blank object
- userRoute = App.UserRoute.create({
- router: {
- container: container,
- router: {}
- },
- container: container
- });
- });
-
- // after each unit test
- afterEach(function () {
- // deleting all objects created for the test, to reset state
- container = userRoute = null;
- });
-
- it("setupController should initialize model and deleteMode", function () {
- // we create controller with a container for the future potential needs
- container.register('controller:user', Em.Object.extend({
- deleteMode: true,
- model: null
- }));
- var userCtrl = container.lookup("controller:user");
- var expectedModel = {}; // fake expected model passed to setupController
-
- userRoute.setupController(userCtrl, expectedModel);
-
- // checking...
- userCtrl.deleteMode.should.be.false;
- userCtrl.model.should.be.equal(expectedModel);
- });
-
-
- it('goBack event should transitionTo users',function(){
- var transitionToRouteCall =0;
-
- // a few dirty, but no idea to how to unit test by another manner
- userRoute.events.transitionTo = function(route){
- // we check if the targeted route by the transition
- // is the 'user' route
- route.should.be.equal('users');
- // we increment the number of call of the transitionToRoute
- transitionToRouteCall++;
- }
- userRoute.events.goBack();
-
- // checking ...
- transitionToRouteCall.should.be.equal(1);
- });
-});
View
53 tests/unit/routes/UsersCreateRoute.test.js
@@ -1,53 +0,0 @@
-describe('UsersCreateRoute', function () {
-
- // common UsersCreateRoute instance
- var usersCreateRoute;
-
- // container of injection of dependencies
- var container;
-
- // before each unit test
- beforeEach(function () {
-
- // we create a new container to isolate the unit test
- container = new Em.Container();
-
- // instantiation by passing it the container previously created in two
- // locations. The first in the route itself and the second in the router.
- // we need too to mock the 'router' instance with a blank object
- usersCreateRoute = App.UsersCreateRoute.create({
- router: {
- container: container,
- router: {}
- },
- container: container
- });
- });
-
- // after each unit test
- afterEach(function () {
- // deleting all objects created for the test, to reset state
- container = usersCreateRoute = null;
- });
-
- it.skip("'s model should create a new instance each time", function () { // no comment ...
- usersCreateRoute.model().should.have.property('id').and.not.empty;
- });
-
- it("'s renderTemplate should render the userEdit template with the userCreate", function(){
- var renderCall = 0;
- usersCreateRoute.render = function(templateName, additionalParams){
- // count the number of call
- renderCall++;
- // check the input parameters
- templateName.should.be.equal('user.edit');
- additionalParams.should.have.property('controller').and.be.equal('usersCreate');
- };
-
- usersCreateRoute.renderTemplate();
-
- // check the number of call
- renderCall.should.be.equal(1);
- });
-
-});
View
57 tests/unit/routes/UsersRoute.test.js
@@ -1,57 +0,0 @@
-describe('UsersRoute', function () {
-
- // common UsersRoute instance
- var usersRoute;
-
- // container of injection of dependencies
- var container;
-
- var userClass;
-
- // before each unit test
- beforeEach(function () {
-
- // we backup the User class
- userClass = App.User;
-
- // we create a new container to isolate the unit test
- container = new Em.Container();
-
- // instantiation by passing it the container previously created in two
- // locations. The first in the route itself and the second in the router.
- // we need too to mock the 'router' instance with a blank object
- usersRoute = App.UsersRoute.create({
- router: {
- container: container,
- router: {}
- },
- container: container
- });
- });
-
- // after each unit test
- afterEach(function () {
- // deleting all objects created for the test, to reset state
- container = usersRoute = null;
-
- // we restore the user class
- App.User = userClass;
- });
-
- it("'s model should return the user list", function () {
- // to count the number of call
- var findCall = 0;
- App.User.reopenClass({
- find: function (){
- // count the number of call
- findCall++;
- // verify that find is call without parameters
- arguments.should.be.empty;
- }
- });
- usersRoute.model();
- // check the number of call
- findCall.should.be.equal(1);
- });
-
-});
View
63 tests/unit/routes/userEditRoute.test.js
@@ -1,63 +0,0 @@
-describe('UserEditRoute', function () {
-
- // common UserEditRoute instance
- var userEditRoute;
-
- // container of injection of dependencies
- var container;
-
- // before each unit test
- beforeEach(function () {
-
- // we create a new container to isolate the unit test
- container = new Em.Container();
-
- // instantiation by passing it the container previously created in two
- // locations. The first in the route itself and the second in the router.
- // we need too to mock the 'router' instance with a blank object
- userEditRoute = App.UserEditRoute.create({
- router: {
- container: container,
- router: {}
- },
- container: container
- });
- });
-
- // after each unit test
- afterEach(function () {
- // deleting all objects created for the test, to reset state
- container = userEditRoute = null;
- });
-
- it("the model is that this parent route, the UserRoute", function () {
- // we create model who will be return by the fake UserRoute
- var expectedUserModel = Em.Object.create({name: 'Model from user route'});
-
- // we register a faked UserRoute with the mocked model
- container.register("route:user", Em.Route.extend({
- currentModel: expectedUserModel
- }));
-
- // we check that when we call the model method of UserEditRoute,
- // it's return the model of the UserRoute
- userEditRoute.model().should.be.equal(expectedUserModel);
- });
-
- it('goBack event should transitionTo users',function(){
- var transitionToRouteCall =0;
-
- // a few dirty, but no idea to how to unit test by another manner
- userEditRoute.events.transitionTo = function(route){
- // we check if the targeted route by the transition
- // is the 'user' route
- route.should.be.equal('user');
- // we increment the number of call of the transitionToRoute
- transitionToRouteCall++;
- }
- userEditRoute.events.goBack();
-
- // checking ...
- transitionToRouteCall.should.be.equal(1);
- });
-});
View
48 tests/unit/views/ModalView.test.js
@@ -1,48 +0,0 @@
-describe('ModalView', function () {
-
- var container;
- var view;
- var $fixture;
-
- before(function () {
- $fixture = $('<div id="view-fixture"></div>').appendTo($('body'));
- container = new Em.Container();
- });
-
- after(function () {
- $fixture.remove();
- });
-
- afterEach(function () {
- Em.run(function () {
- if (view) {
- view.destroy();
- }
- });
- container = null;
- });
-
- it('when backdrop is clicked the model close', function () {
- var fakeCtrl = Em.Object.create({
- modalVisible: true
- });
-
- container.register('template:modal', Em.Handlebars.compile(''), { instantiate: false });
- container.register('template:modal_layout', Em.TEMPLATES['modal_layout'], { instantiate: false });
-
- container.register('view:modal', App.Modal.extend({
- templateName : 'modal',
- controller: fakeCtrl
- }));
-
- view = container.lookup('view:modal');
- Ember.run(function () {
- view.appendTo($fixture);
- });
-
- Em.run(function () {
- $('.modal-backdrop').click();
- });
- fakeCtrl.modalVisible.should.be.false;
- });
-});
View
59 tests/unit/views/confirmDeleteButtonView.test.js
@@ -1,59 +0,0 @@
-describe('confirmDeleteButtonView',function(){
-
- var view;
- var $fixture;
-
- var wait = function(callback, maxWaitCount) {
- maxWaitCount = Ember.isNone(maxWaitCount) ? 100 : maxWaitCount;
-
- setTimeout(function() {
- if (maxWaitCount > 0 && (Ember.run.hasScheduledTimers() || Ember.run.currentRunLoop)) {
- wait(callback, maxWaitCount - 1);
-
- return;
- }
-
- callback();
- }, 10);
- };
-
- before(function () {
- $fixture = $('<div id="view-fixture"></div>').appendTo($('body'));
- });
-
- after(function () {
- $fixture.remove();
- });
-
- afterEach(function () {
- Em.run(function () {
- if (view) {
- view.destroy();
- }
- });
- });
-
- it('Should add css class on its "user-profile" parent and call confirmeDelete on its controller ',function(done){
- var confirmDeleteCall = 0;
- view = App.ConfirmDeleteButtonView.create({
- controller: {
- confirmDelete:function(){
- confirmDeleteCall++;
- }
- }
- });
- var $userProfile = $('<div class="user-profile"></div>');
- $userProfile.appendTo($fixture);
- Ember.run(function () {
- view.appendTo($userProfile);
- });
- view.click();
-
- wait(function(){
- confirmDeleteCall.should.equal(1);
- $userProfile.hasClass('delete-animation').should.be.true;
- $userProfile.remove();
- done();
- },600);
- });
-});
Please sign in to comment.
Something went wrong with that request. Please try again.