Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update account.spec.ts #1

Open
wants to merge 1 commit into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Update account.spec.ts

hi Lisi ,when using Jest you do not need an external chai library to use expect. Jest has built in expect assertions
https://jestjs.io/docs/en/expect.html#expectvalue
  • Loading branch information...
toyerma committed Jun 22, 2019
commit 8853f704d1e12cefa46cc9059594ff7ab9321755
@@ -2,8 +2,6 @@ import { browser, element, by, ExpectedConditions as ec } from 'protractor';

import { NavBarPage, SignInPage, PasswordPage, SettingsPage } from '../page-objects/jhi-page-objects';

const expect = chai.expect;

describe('account', () => {
let navBarPage: NavBarPage;
let signInPage: SignInPage;
@@ -18,13 +16,13 @@ describe('account', () => {
it('should fail to login with bad password', async () => {
const expect1 = 'Welcome, Java Hipster!';
const value1 = await element(by.css('h1')).getText();
expect(value1).to.eq(expect1);
expect(value1).toEqual(expect1);
signInPage = await navBarPage.getSignInPage();
await signInPage.autoSignInUsing('admin', 'foo');

const expect2 = 'Failed to sign in! Please check your credentials and try again.';
const value2 = await element(by.css('.alert-danger')).getText();
expect(value2).to.eq(expect2);
expect(value2).toEqual(expect2);
});

it('should login successfully with admin account', async () => {
@@ -33,33 +31,33 @@ describe('account', () => {

const expect1 = 'Login';
const value1 = await element(by.className('username-label')).getText();
expect(value1).to.eq(expect1);
expect(value1).toEqual(expect1);
await signInPage.autoSignInUsing('admin', 'admin');

const expect2 = 'You are logged in as user "admin".';
await browser.wait(ec.visibilityOf(element(by.id('home-logged-message'))));
const value2 = await element(by.id('home-logged-message')).getText();
expect(value2).to.eq(expect2);
expect(value2).toEqual(expect2);
});

it('should be able to update settings', async () => {
settingsPage = await navBarPage.getSettingsPage();

const expect1 = 'User settings for [admin]';
const value1 = await settingsPage.getTitle();
expect(value1).to.eq(expect1);
expect(value1).toEqual(expect1);
await settingsPage.save();

const expect2 = 'Settings saved!';
const alert = element(by.css('.alert-success'));
const value2 = await alert.getText();
expect(value2).to.eq(expect2);
expect(value2).toEqual(expect2);
});

it('should fail to update password when using incorrect current password', async () => {
passwordPage = await navBarPage.getPasswordPage();

expect(await passwordPage.getTitle()).to.eq('Password for [admin]');
expect(await passwordPage.getTitle()).toEqual('Password for [admin]');

await passwordPage.setCurrentPassword('wrong_current_password');
await passwordPage.setPassword('new_password');
@@ -69,14 +67,14 @@ describe('account', () => {
const expect2 = 'An error has occurred! The password could not be changed.';
const alert = element(by.css('.alert-danger'));
const value2 = await alert.getText();
expect(value2).to.eq(expect2);
expect(value2).toEqual(expect2);
settingsPage = await navBarPage.getSettingsPage();
});

it('should be able to update password', async () => {
passwordPage = await navBarPage.getPasswordPage();

expect(await passwordPage.getTitle()).to.eq('Password for [admin]');
expect(await passwordPage.getTitle()).toEqual('Password for [admin]');

await passwordPage.setCurrentPassword('admin');
await passwordPage.setPassword('newpassword');
@@ -86,7 +84,7 @@ describe('account', () => {
const expect2 = 'Password changed!';
const alert = element(by.css('.alert-success'));
const value2 = await alert.getText();
expect(value2).to.eq(expect2);
expect(value2).toEqual(expect2);
await navBarPage.autoSignOut();
await navBarPage.goToSignInPage();
await signInPage.autoSignInUsing('admin', 'newpassword');
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.