Skip to content

Commit

Permalink
feat: call ghost api at hatchout [ISSUE:#39]
Browse files Browse the repository at this point in the history
  • Loading branch information
ttkmw committed Mar 14, 2020
1 parent c26d024 commit 9181757
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/api/ghost/ghost.api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ describe('GhostApi', () => {
const domain = 'ghosts';
describe('getByPage()', () => {
const page = 1;
it('should return ghosts', async () => {
responseData = {name: 'name', address: 'address', point: 1, level: 1};
it('should return ghosts', async () => {
responseData = {
name: 'Token Name1',
gene: 'token ID',
tokenId: 1,
userAddress: 'user1',
level: 1,
angelPoint: 10,
devilPoint: 20,
createdDate: Date.now(),
};
mockAdapter.onGet(`/${domain}?page=${page}`).reply(200, responseData);

expect(await ghostApi.getByPage(page)).toEqual(responseData);
Expand Down
2 changes: 1 addition & 1 deletion src/api/user/user.api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {UserApi} from '@/api/user/user.api';
import {AxiosSupplier} from '@/api/axios/axios.supplier';
import {HttpClient} from '@/api/axios/http.client';

describe('UserApi', () => {
describe('UserApi', () => {

const mockAdapter = new MockAdapter(axios);
const mockAxiosSupplier = mock(AxiosSupplier);
Expand Down
4 changes: 4 additions & 0 deletions src/components/sections/MarketPlaceSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import GhostTable from '@/components/tables/GhostTable.vue';
import {Inject} from "vue-typedi";
import tokens from "@/store/tokens";
import {UserModule} from "@/store/modules/user";
import {GhostModule} from "@/store/modules/ghost";
@Component({
components: { GhostCard, GhostTable},
Expand All @@ -40,6 +41,9 @@ export default class MarketPlaceSection extends Vue {
@Inject(tokens.USER_MODULE)
public userModule!: UserModule;
@Inject(tokens.GHOST_MODULE)
public ghostModule!: GhostModule;
constructor() {
super();
this.currentNum = 1;
Expand Down
8 changes: 7 additions & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vue from 'vue';
import Vuex from 'vuex';

import { createVuexStore } from 'vuex-simple';
import {createVuexStore} from 'vuex-simple';
import {Store} from './store';
import {Container} from 'vue-typedi';
import tokens from './tokens';
Expand All @@ -12,6 +12,7 @@ Vue.use(Vuex);
const instance = new Store();

Container.set(tokens.USER_MODULE, instance.userModule);
Container.set(tokens.GHOST_MODULE, instance.ghostModule);

export const store = createVuexStore(instance, {
strict: false,
Expand All @@ -20,3 +21,8 @@ export const store = createVuexStore(instance, {

});

// todo: move to config
const initPage: number = 1;
// todo: handle error correctly
instance.ghostModule.getGhostsByPage(initPage).then().catch();

1 change: 1 addition & 0 deletions src/store/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import {Token} from 'typedi';

export default {
USER_MODULE: new Token(),
GHOST_MODULE: new Token(),
};

0 comments on commit 9181757

Please sign in to comment.