Skip to content

Commit

Permalink
WIP: store testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed May 7, 2020
1 parent 2ab2ec3 commit b5d9938
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
8 changes: 6 additions & 2 deletions karma.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ process.env.CHROME_BIN = require('puppeteer').executablePath();
export default (config: Karma.Config) => {
const configuration: Karma.ConfigOptions = {
basePath: '',
browsers: ['KarmaChromeHeadless'],
browsers: process.env.CI ? ['KarmaChromeHeadless'] : ['KarmaChrome'],
customLaunchers: {
KarmaChromeHeadless: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
flags: ['--no-sandbox', '--disable-web-security']
},
KarmaChrome: {
base: 'Chrome',
flags: ['--no-sandbox', '--disable-web-security']
}
},
files: ['test/loadtests.ts'],
Expand Down
2 changes: 1 addition & 1 deletion src/stores/GalleryStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { observable } from 'mobx';
import { useLocalStore } from 'mobx-react-lite';
import * as api from '@/utils/api';

const createStore = () => {
export const createStore = () => {
const store = observable({
page: 1,
isFetching: false,
Expand Down
11 changes: 11 additions & 0 deletions test/stores/GalleryStoreTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect } from 'chai';
import { createStore } from '@/stores/GalleryStore';

describe('stores', () => {
const store = createStore();
it('fetch ranking', async () => {
store.setWord('ranking');
await store.fetchSource();
expect(store.items).to.have.lengthOf.at.least(1);
});
});
15 changes: 15 additions & 0 deletions test/utils/apiTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { expect } from 'chai';
import * as api from '@/utils/api';
import config from '@/config';

describe('api', () => {
it('proxy pixiv image', () => {
expect(
api.proxyImage(
'https://i.pximg.net/c/600x1200_90/img-master/img/2020/04/24/18/00/10/81026143_p0_master1200.jpg'
)
).to.equal(
`${config.apiBaseURL}/image/i.pximg.net/c/600x1200_90/img-master/img/2020/04/24/18/00/10/81026143_p0_master1200.jpg`
);
});
});

0 comments on commit b5d9938

Please sign in to comment.