Commit 38be48f8 authored by Laurent's avatar Laurent

start Iguana adapter

parent b2e67007
import {PortalAdapter} from './adapter';
import * as cheerio from 'cheerio';
import {Account, Loan, Hold} from '../../models';
import {WrongLoginPassword} from './wrong-login-password';
export class IguanaV3 extends PortalAdapter {
public getIdentifier(): string {
return 'iguana-v3';
}
public getLabel(): string {
return 'Iguana 3';
}
public canHandleWebsite($): boolean {
return $('a[href*="www.main.cls?sUrl="]').length;
}
protected _fetchLoans(account: Account): Promise<Array<Loan>> {
return Promise.resolve(new Array<Loan>());
}
protected _signIn(account): Promise<any> {
return Promise.resolve();
}
}
......@@ -9,4 +9,5 @@ export {KohaCas} from './koha-cas';
export {InMedia} from './inmedia';
export {Symphony} from './symphony';
export {InMediaV2} from './inmedia-v2';
export {IguanaV3} from './iguana-v3';
export {Autodetect} from './autodetect';
......@@ -60,8 +60,8 @@ describe('AccountsController with one account in database', () => {
})
it('form selectedPortalIndex should be nine', () => {
expect(account_form.get('selectedPortalIndex')).to.equal(9);
it('form selectedPortalIndex should be ten', () => {
expect(account_form.get('selectedPortalIndex')).to.equal(10);
})
......
......@@ -106,3 +106,12 @@ export class AutodetectKohaCASUL3 extends AutodetectScenario {
}
}
export class AutodetectIguana3 extends AutodetectScenario {
public frontPage():string {
return this._encapsulate('\
<a abp="3116" href="www.main.cls?sUrl=ulw">');
}
}
......@@ -8,7 +8,8 @@ import {AutodetectOrpheemedia,
AutodetectBokeh,
AutodetectKoha,
AutodetectKohaCASUL2,
AutodetectKohaCASUL3} from './autodetect-fixtures';
AutodetectKohaCASUL3,
AutodetectIguana3} from './autodetect-fixtures';
describe('Account with autodetect adapter', () => {
let adapter: Autodetect;
......@@ -119,4 +120,17 @@ describe('Account with autodetect adapter', () => {
expect(account.getAdapterIdentifier()).to.equals('koha-cas');
});
});
it('should detect Iguana3', () => {
return adapter
.setHTTP(new AutodetectIguana3('http://ulw.fr'))
.refresh(account).then(
() => {
expect.fail('WrongLoginPassword error should be thrown');
},
() => {
expect(account.getAdapterIdentifier()).to.equals('iguana-v3');
});
});
});
declare var expect: any;
import {HTTPScenario} from './http-scenario';
class IguanaV3LoansAndHoldsWithSuccessfulLogin extends HTTPScenario {
public constructor(base_url: string) {
super();
this.setup(base_url);
}
public setup(base_url:string) {
this.expect({ url: base_url + 'empr.php',
method: "POST",
content: "login=marco&password=polo",
headers: {"Content-Type": "application/x-www-form-urlencoded"} },
{ content: this.frontPageConnected() })
}
public frontPageConnected(): string {
return this._encapsulate('');
}
}
declare var describe, expect, it, before, beforeEach, chai: any;
import {Loan, Hold, Account, Database, WrongLoginPassword, Portal} from '../../models/';
import {IguanaV3} from '../../models/portal/iguana-v3';
import {IguanaV3LoansAndHoldsWithSuccessfulLogin} from './iguana-v3-fixtures';
describe('Account on IguanaV3', () => {
let adapter: IguanaV3;
let db: Database;
beforeEach( () => {
db = Database.open('testdb').clear();
adapter = new IguanaV3();
});
describe('With successful Login scenario', () => {
let account;
beforeEach( () => {
account = (new Account())
.setUrl('iguana.fr')
.setCredentials({login: 'marco',
password: 'polo',
portal: 'iguana-v3'});
db.save(account);
});
it('db should have three loans and one hold', () => {
})
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment