Browse Source

fixed tests suite

Rafał Pitoń 10 years ago
parent
commit
b402fa4e2b

+ 5 - 3
misago/emberapp/app/services/toast-message.js

@@ -14,9 +14,11 @@ export default Ember.Service.extend({
 
 
   _showToast: function(type, message) {
   _showToast: function(type, message) {
     var toastId = this.incrementProperty('id');
     var toastId = this.incrementProperty('id');
-    this.set('type', type);
-    this.set('message', message);
-    this.set('isVisible', true);
+    this.setProperties({
+      'type': type,
+      'message': message,
+      'isVisible': true
+    });
 
 
     var displayTime = ENV.APP.TOAST_BASE_DISPLAY_TIME;
     var displayTime = ENV.APP.TOAST_BASE_DISPLAY_TIME;
     displayTime += message.length * ENV.APP.TOAST_LENGTH_FACTOR;
     displayTime += message.length * ENV.APP.TOAST_LENGTH_FACTOR;

+ 4 - 4
misago/emberapp/tests/acceptance/document-title-mixin-test.js

@@ -12,12 +12,12 @@ module('Acceptance: Page Title Mixin', {
     application = startApp();
     application = startApp();
     container = application.__container__;
     container = application.__container__;
 
 
-    forum_name = container.resolve('misago:settings').forum_name;
+    forum_name = container.lookup('misago:settings').forum_name;
   },
   },
 
 
   afterEach: function() {
   afterEach: function() {
     document.title = title;
     document.title = title;
-    container.resolve('misago:settings').forum_name = forum_name;
+    container.lookup('misago:settings').forum_name = forum_name;
 
 
     Ember.run(application, 'destroy');
     Ember.run(application, 'destroy');
   }
   }
@@ -27,10 +27,10 @@ test('setTitle changes document title', function(assert) {
   assert.expect(5);
   assert.expect(5);
 
 
   var TestRoute = Ember.Object.extend(DocumentTitle, {
   var TestRoute = Ember.Object.extend(DocumentTitle, {
-    settings: container.resolve('misago:settings')
+    settings: container.lookup('misago:settings')
   });
   });
 
 
-  container.resolve('misago:settings').forum_name = 'Test Forum';
+  container.lookup('misago:settings').forum_name = 'Test Forum';
 
 
   var mixin = TestRoute.create();
   var mixin = TestRoute.create();
 
 

+ 2 - 0
misago/emberapp/tests/acceptance/zxcvbn-service-test.js

@@ -17,12 +17,14 @@ module('Acceptance: ZxcvbnService', {
 });
 });
 
 
 test('loading zxcvbn and testing password with it', function(assert) {
 test('loading zxcvbn and testing password with it', function(assert) {
+  var done = assert.async();
   assert.expect(2);
   assert.expect(2);
 
 
   Ember.run(function() {
   Ember.run(function() {
     service.loadLibrary().then(function() {
     service.loadLibrary().then(function() {
       assert.ok(typeof zxcvbn !== 'undefined');
       assert.ok(typeof zxcvbn !== 'undefined');
       assert.ok(service.scorePassword('L0r3m !p5um') > 0);
       assert.ok(service.scorePassword('L0r3m !p5um') > 0);
+        done();
     });
     });
   });
   });
 });
 });

+ 2 - 2
misago/emberapp/tests/unit/initializers/auth-service-test.js

@@ -19,6 +19,6 @@ test('initializer registered auth and user', function(assert) {
 
 
   initialize(container, application);
   initialize(container, application);
 
 
-  assert.ok(container.has('misago:auth'));
-  assert.ok(container.has('misago:user'));
+  assert.ok(container.lookup('misago:auth'));
+  assert.ok(container.lookup('misago:user'));
 });
 });

+ 1 - 1
misago/emberapp/tests/unit/initializers/django-location-test.js

@@ -19,6 +19,6 @@ test('initializer registers location api', function(assert) {
 
 
   initialize(container, application);
   initialize(container, application);
 
 
-  assert.ok(container.has('location:django-location'));
+  assert.ok(application.registry.has('location:django-location'));
 });
 });
 
 

+ 0 - 1
misago/emberapp/tests/unit/mixins/document-title-test.js

@@ -14,7 +14,6 @@ module('DocumentTitleMixin', {
   }
   }
 });
 });
 
 
-// Replace this with your real tests.
 test('it works', function(assert) {
 test('it works', function(assert) {
   var DocumentTitleObject = Ember.Object.extend(DocumentTitleMixin);
   var DocumentTitleObject = Ember.Object.extend(DocumentTitleMixin);
   var subject = DocumentTitleObject.create();
   var subject = DocumentTitleObject.create();

+ 0 - 1
misago/emberapp/tests/unit/mixins/reset-scroll-test.js

@@ -4,7 +4,6 @@ import { module, test } from 'qunit';
 
 
 module('ResetScrollMixin');
 module('ResetScrollMixin');
 
 
-// Replace this with your real tests.
 test('it works', function(assert) {
 test('it works', function(assert) {
   assert.expect(1);
   assert.expect(1);
 
 

+ 11 - 0
misago/emberapp/tests/unit/services/toast-message-test.js

@@ -1,3 +1,4 @@
+import Ember from 'ember';
 import {
 import {
   moduleFor,
   moduleFor,
   test
   test
@@ -65,6 +66,7 @@ test('isError', function(assert) {
 });
 });
 
 
 test('_setToast', function(assert) {
 test('_setToast', function(assert) {
+  var done = assert.async();
   assert.expect(3);
   assert.expect(3);
 
 
   var service = this.subject();
   var service = this.subject();
@@ -76,9 +78,14 @@ test('_setToast', function(assert) {
   assert.ok(service.get('isVisible'));
   assert.ok(service.get('isVisible'));
   assert.ok(service.get('isSuccess'));
   assert.ok(service.get('isSuccess'));
   assert.equal(service.get('message'), testMessage);
   assert.equal(service.get('message'), testMessage);
+
+  setTimeout(function() {
+    done();
+  }, 750);
 });
 });
 
 
 test('_showToast', function(assert) {
 test('_showToast', function(assert) {
+  var done = assert.async();
   assert.expect(3);
   assert.expect(3);
 
 
   var service = this.subject();
   var service = this.subject();
@@ -90,4 +97,8 @@ test('_showToast', function(assert) {
   assert.ok(service.get('isVisible'));
   assert.ok(service.get('isVisible'));
   assert.ok(service.get('isSuccess'));
   assert.ok(service.get('isSuccess'));
   assert.equal(service.get('message'), testMessage);
   assert.equal(service.get('message'), testMessage);
+
+  setTimeout(function() {
+    done();
+  }, 750);
 });
 });