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', () => {
it('should return the company', () => {
controller.companyId = null;
expect(controller._companyId).toEqual(jasmine.any(Object));
});
it('should return the company and then call getData()', () => {
spyOn(controller, 'getData');
controller.companyId = 442;

View File

@ -5,7 +5,7 @@ describe('travel getEntry()', () => {
it('should check the entry contains the id', async() => {
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() => {

View File

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

View File

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