Skip to content

Commit 8dce663

Browse files
committed
fix(test): use proper controlFlow in protractor tests
1 parent f34e8f3 commit 8dce663

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Diff for: app/templates/e2e/account(auth)/signup/signup.spec(jasmine).js

+9-9
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ describe('Signup View', function() {
3535

3636
describe('with local auth', function() {
3737

38-
it('should signup a new user, log them in, and redirecting to "/"', function(done) {
39-
<% if (filters.mongooseModels) { %>UserModel.remove(function() {<% }
40-
if (filters.sequelizeModels) { %>UserModel.destroy({ where: {} }).then(function() {<% } %>
41-
page.signup(testUser);
38+
beforeAll(function(done) {
39+
<% if (filters.mongooseModels) { %>UserModel.removeAsync().then(done);<% }
40+
if (filters.sequelizeModels) { %>UserModel.destroy({ where: {} }).then(done);<% } %>
41+
});
4242

43-
var navbar = require('../../components/navbar/navbar.po');
43+
it('should signup a new user, log them in, and redirecting to "/"', function() {
44+
page.signup(testUser);
4445

45-
expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/');
46-
expect(navbar.navbarAccountGreeting.getText()).toBe('Hello ' + testUser.name);
46+
var navbar = require('../../components/navbar/navbar.po');
4747

48-
done();
49-
});
48+
expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/');
49+
expect(navbar.navbarAccountGreeting.getText()).toBe('Hello ' + testUser.name);
5050
});
5151

5252
it('should indicate signup failures', function() {

Diff for: app/templates/e2e/account(auth)/signup/signup.spec(mocha).js

+9-9
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ describe('Signup View', function() {
4040

4141
describe('with local auth', function() {
4242

43-
it('should signup a new user, log them in, and redirecting to "/"', function(done) {
44-
<% if (filters.mongooseModels) { %>UserModel.remove(function() {<% }
45-
if (filters.sequelizeModels) { %>UserModel.destroy({ where: {} }).then(function() {<% } %>
46-
page.signup(testUser);
43+
before(function() {
44+
<% if (filters.mongooseModels) { %>return UserModel.removeAsync();<% }
45+
if (filters.sequelizeModels) { %>return UserModel.destroy({ where: {} });<% } %>
46+
})
4747

48-
var navbar = require('../../components/navbar/navbar.po');
48+
it('should signup a new user, log them in, and redirecting to "/"', function() {
49+
page.signup(testUser);
4950

50-
<%= does("browser.getLocationAbsUrl()") %>.eventually.equal(config.baseUrl + '/');
51-
<%= does("navbar.navbarAccountGreeting.getText()") %>.eventually.equal('Hello ' + testUser.name);
51+
var navbar = require('../../components/navbar/navbar.po');
5252

53-
done();
54-
});
53+
<%= does("browser.getLocationAbsUrl()") %>.eventually.equal(config.baseUrl + '/');
54+
<%= does("navbar.navbarAccountGreeting.getText()") %>.eventually.equal('Hello ' + testUser.name);
5555
});
5656

5757
describe('and invalid credentials', function() {

0 commit comments

Comments
 (0)