...
 
Commits (2)
......@@ -115,7 +115,7 @@ describe('LoginComponent', () => {
);
expect(h3).not.toBeNull();
expect(h3.nativeElement.textContent).toContain(
'Not on Minds? Start a channel'
'Not on Minds? Start a Minds channel'
);
expect(
fixture.debugElement.query(By.css('minds-form-register'))
......
......@@ -106,6 +106,11 @@ describe('ChannelSidebar', () => {
selector: 'm-channel-mode-selector',
inputs: ['user', 'enabled'],
}),
MockComponent({
selector: 'm-tooltip',
template: '<ng-content></ng-content>',
inputs: ['icon', 'iconClass'],
}),
IfFeatureDirective,
],
imports: [FormsModule, RouterTestingModule, NgCommonModule],
......@@ -140,6 +145,7 @@ describe('ChannelSidebar', () => {
fixture = TestBed.createComponent(ChannelSidebar);
featuresServiceMock.mock('es-feeds', false);
featuresServiceMock.mock('permissions', true);
featuresServiceMock.mock('pro', true);
clientMock.response = {};
uploadMock.response = {};
comp = fixture.componentInstance;
......
......@@ -220,9 +220,9 @@ export function getSocialProfileMeta(key: string): SocialProfileMeta {
return defaultMeta;
}
for (let i in this.socialProfilesMeta) {
if (this.socialProfilesMeta[i].key === key) {
return this.socialProfilesMeta[i];
for (let i in socialProfileMeta) {
if (socialProfileMeta[i].key === key) {
return socialProfileMeta[i];
}
}
......
......@@ -28,9 +28,6 @@ describe('LoginForm', () => {
let loginButton: DebugElement;
let errorMessage: DebugElement;
let twoFactorForm: DebugElement;
let twoFactorCode: DebugElement;
let twoFactorLoginButton: DebugElement;
let session: Session;
function login(response, _username = 'username') {
......@@ -52,6 +49,7 @@ describe('LoginForm', () => {
}
function twoFactorLogin(response) {
const twoFactorCode = getTwoFactorCode();
twoFactorCode.nativeElement.value = '123123';
twoFactorCode.nativeElement.dispatchEvent(new Event('input'));
......@@ -62,12 +60,24 @@ describe('LoginForm', () => {
tick();
fixture.detectChanges();
twoFactorLoginButton.nativeElement.click();
getTwoFactorLoginButton().nativeElement.click();
tick();
fixture.detectChanges();
}
function getTwoFactorForm() {
return fixture.debugElement.query(By.css('.minds-login-box:last-of-type'));
}
function getTwoFactorCode() {
return fixture.debugElement.query(By.css('#code'));
}
function getTwoFactorLoginButton() {
return fixture.debugElement.query(By.css('.mdl-card > button'));
}
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
......@@ -95,13 +105,6 @@ describe('LoginForm', () => {
password = fixture.debugElement.query(By.css('#password'));
loginButton = fixture.debugElement.query(By.css('.m-btn--login'));
errorMessage = fixture.debugElement.query(By.css('.m-error-box'));
twoFactorForm = fixture.debugElement.query(
By.css('.minds-login-box:last-of-type')
);
twoFactorCode = fixture.debugElement.query(By.css('#code'));
twoFactorLoginButton = fixture.debugElement.query(
By.css('.mdl-card > button')
);
session = comp.session;
......@@ -244,7 +247,8 @@ describe('LoginForm', () => {
login({ status: 'error', code: '403', message: 'imaprettymessage' });
expect(loginForm.nativeElement.hidden).toBeTruthy();
expect(twoFactorForm.nativeElement.hidden).toBeFalsy();
expect(getTwoFactorForm().nativeElement.hidden).toBeFalsy();
}));
it('should spawn error message when incorrect code is written', fakeAsync(() => {
......
......@@ -122,6 +122,7 @@ describe('NewsfeedComponent', () => {
clientMock.response = {};
featuresServiceMock.mock('top-feeds', false);
featuresServiceMock.mock('suggested-users', false);
featuresServiceMock.mock('pro', false);
sessionMock.user.admin = false;
sessionMock.loggedIn = true;
......
......@@ -23,7 +23,7 @@ import { sessionMock } from '../../../tests/session-mock.spec';
import { ExcerptPipe } from '../../common/pipes/excerpt';
describe('NotificationsComponent', () => {
describe('NotificationComponent', () => {
let comp: NotificationComponent;
let fixture: ComponentFixture<NotificationComponent>;
......@@ -248,7 +248,7 @@ describe('NotificationsComponent', () => {
fixture.detectChanges();
expect(comp.notification).not.toBeNull();
const notification = fixture.debugElement.query(By.css('p'));
expect(notification.nativeElement.innerHTML).toBe(
expect(notification.nativeElement.innerHTML).toContain(
'name tagged you in a post'
);
});
......@@ -276,7 +276,7 @@ describe('NotificationsComponent', () => {
fixture.detectChanges();
expect(comp.notification).not.toBeNull();
const notification = fixture.debugElement.query(By.css('p'));
expect(notification.nativeElement.innerHTML).toBe(
expect(notification.nativeElement.innerHTML).toContain(
'name tagged you in a comment'
);
});
......@@ -518,7 +518,7 @@ describe('NotificationsComponent', () => {
fixture.detectChanges();
expect(comp.notification).not.toBeNull();
const notification = fixture.debugElement.query(By.css('p'));
expect(notification.nativeElement.innerHTML).toBe(
expect(notification.nativeElement.innerHTML).toContain(
'You can gain more reach by boosting your content. Hit the blue boost icon on your posts.'
);
});
......
......@@ -3,7 +3,17 @@ import { clientMock } from '../../../tests/client-mock.spec';
import { sessionMock } from '../../../tests/session-mock.spec';
import { socketMock } from '../../../tests/socket-mock.spec';
import { fakeAsync, tick } from '@angular/core/testing';
import { mindsTitleMock } from '../../../app/mocks/services/ux/minds-title.service.mock.spec';
import { mindsTitleMock } from '../../mocks/services/ux/minds-title.service.mock.spec';
import { MockService } from '../../utils/mock';
import { SiteService } from '../../services/site.service';
import { EventEmitter } from '@angular/core';
export let siteServiceMock = new (function() {
var pro = () => null;
var isProDomain = () => false;
var title = () => 'Minds';
var isAdmin = () => true;
})();
describe('NewsfeedService', () => {
let service: NotificationService;
......@@ -12,10 +22,11 @@ describe('NewsfeedService', () => {
jasmine.clock().uninstall();
jasmine.clock().install();
service = new NotificationService(
clientMock,
sessionMock,
clientMock,
socketMock,
mindsTitleMock
mindsTitleMock,
siteServiceMock
);
clientMock.response = {};
});
......