fix test
gitea/salix/2056-entry_descriptor This commit looks good Details

This commit is contained in:
Bernat Exposito Domenech 2020-02-25 10:39:21 +01:00
parent e7cdc58fad
commit b37e8da410
4 changed files with 12 additions and 16 deletions

View File

@ -44,12 +44,6 @@ describe('Client', () => {
}); });
describe('company setter/getter', () => { describe('company setter/getter', () => {
it('should return the company', () => {
controller.companyId = null;
expect(controller._companyId).toEqual(jasmine.any(Object));
});
it('should return the company and then call getData()', () => { it('should return the company and then call getData()', () => {
spyOn(controller, 'getData'); spyOn(controller, 'getData');
controller.companyId = 442; controller.companyId = 442;

View File

@ -5,7 +5,7 @@ describe('travel getEntry()', () => {
it('should check the entry contains the id', async() => { it('should check the entry contains the id', async() => {
const entry = await app.models.Entry.getEntry(entryId); const entry = await app.models.Entry.getEntry(entryId);
expect(entry.id).toEqual(1); expect(entry.id).toEqual(entryId);
}); });
it('should check the entry contains the supplier name', async() => { it('should check the entry contains the supplier name', async() => {

View File

@ -16,10 +16,10 @@ class Controller extends Component {
this._entry = value; this._entry = value;
if (value && value.id) if (value && value.id)
this.getEntry(); this.getEntryData();
} }
getEntry() { getEntryData() {
return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => { return this.$http.get(`/api/Entries/${this.entry.id}/getEntry`).then(response => {
this.entryData = response.data; this.entryData = response.data;
}); });

View File

@ -18,28 +18,30 @@ describe('component vnEntrySummary', () => {
})); }));
describe('entry setter/getter', () => { describe('entry setter/getter', () => {
it('should return the entry', () => { it('should check if value.id is defined', () => {
spyOn(controller, 'getEntryData');
controller.entry = {id: 1}; controller.entry = {id: 1};
expect(controller.entry).toEqual(jasmine.any(Object)); expect(controller.getEntryData).toHaveBeenCalledWith();
}); });
it('should return the entry and then call getEntry()', () => { it('should return the entry and then call getEntryData()', () => {
spyOn(controller, 'getEntry'); spyOn(controller, 'getEntryData');
controller.entry = {id: 99}; controller.entry = {id: 99};
expect(controller._entry.id).toEqual(99); expect(controller._entry.id).toEqual(99);
expect(controller.getEntry).toHaveBeenCalledWith(); expect(controller.getEntryData).toHaveBeenCalledWith();
}); });
}); });
describe('getEntry()', () => { describe('getEntryData()', () => {
it('should perform a get and then store data on the controller', () => { it('should perform a get and then store data on the controller', () => {
controller._entry = {id: 999}; controller._entry = {id: 999};
const query = `/api/Entries/${controller._entry.id}/getEntry`; const query = `/api/Entries/${controller._entry.id}/getEntry`;
$httpBackend.expectGET(query).respond('I am the entryData'); $httpBackend.expectGET(query).respond('I am the entryData');
controller.getEntry(); controller.getEntryData();
$httpBackend.flush(); $httpBackend.flush();
expect(controller.entryData).toEqual('I am the entryData'); expect(controller.entryData).toEqual('I am the entryData');