Skip to content

Commit

Permalink
test(e2e): add case
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi committed Feb 26, 2020
1 parent 5e43fb3 commit 5e57ca9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
15 changes: 9 additions & 6 deletions e2e/main.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ describe('Keira3 App', function () {
browser = client as any;
});

// it('should display message saying App works !', async function () {
// const text = await browser.getText('app-home h1');
// expect(text).to.equal('App works !');
// });


it('creates initial windows', async function () {
const count = await client.getWindowCount();
expect(count).to.equal(1);
});

it('sqlite should correctly work', async function () {
const sleep = time => new Promise(r => setTimeout(r, time));
const selector = '#sqlite-e2e-test';
const expectedText = 'Tricks and Treats of Azeroth';
const text = await browser.getAttribute(selector, 'e2e');
await sleep(3000);
expect(text).to.equal(expectedText);
});

});
2 changes: 2 additions & 0 deletions src/app/main/app.component.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<app-connection-window *ngIf="!mysqlService.connectionEstablished"></app-connection-window>
<app-main-window *ngIf="mysqlService.connectionEstablished"></app-main-window>

<div id="sqlite-e2e-test" [attr.e2e]="sqliteResult?.name" style="display: none"></div>
16 changes: 12 additions & 4 deletions src/app/main/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { distinctUntilChanged } from 'rxjs/operators';

import { MysqlService } from '../shared/services/mysql.service';
import { SqliteQueryService } from '@keira-shared/services/sqlite-query.service';
import { ElectronService } from '@keira-shared/services/electron.service';

@Component({
selector: 'app-root',
Expand All @@ -12,10 +13,13 @@ import { SqliteQueryService } from '@keira-shared/services/sqlite-query.service'
})
export class AppComponent implements OnInit {

sqliteResult: { id: number; name: string };

constructor(
public mysqlService: MysqlService,
public toastrService: ToastrService,
public sqliteQueryService: SqliteQueryService,
private sqliteQueryService: SqliteQueryService,
private electronService: ElectronService,
) {}

ngOnInit(): void {
Expand All @@ -30,8 +34,12 @@ export class AppComponent implements OnInit {
});

/* istanbul ignore next */
this.sqliteQueryService.query('SELECT * FROM achievements WHERE id = 42').subscribe((result) => {

});
if (this.electronService.isElectron()) {
this.sqliteQueryService.query<{ id: number, name: string}>(
'SELECT * FROM achievements WHERE id = 970'
).subscribe((result) => {
this.sqliteResult = result;
});
}
}
}

0 comments on commit 5e57ca9

Please sign in to comment.