lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

StorageMock redundant? #241

Closed hfwittmann closed 7 years ago

hfwittmann commented 7 years ago

as far as I can tell the code for StorageMock in src/mock.ts is redundant/not used and should probably be removed. Correct?

export class StorageMock {

  public get(key: string): Promise<{}> {
    return new Promise((resolve: Function) => {
      resolve({});
    });
  }

  public set(key: string, value: string): Promise<{}> {
    return new Promise((resolve: Function) => {
      resolve({key: key, value: value});
    });
  }

  public remove(key: string): Promise<{}> {
    return new Promise((resolve: Function) => {
      resolve({key: key});
    });
  }

  public query(): Promise<{ res: { rows: Array<{}> }}> {
    return new Promise((resolve) => {
      resolve({
        res: {
          rows: [{}]
        }
      });
    });
  }
}
lathonez commented 7 years ago

It's used here: https://github.com/lathonez/clicker/blob/master/src/services/clickers.spec.ts#L10

Query could be removed.

EDIT - sorry, was looking at the wrong file. Yes I think it can be removed.

lathonez commented 7 years ago

Thanks a lot!

hfwittmann commented 7 years ago

Glad to help. After all, this is the best reference for ionic 2 testing.