-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
4,363 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug Jest Tests", | ||
"cwd": "${workspaceFolder}", | ||
"args": [ | ||
"--inspect-brk", | ||
"${workspaceRoot}/node_modules/.bin/jest", | ||
"--runInBand" | ||
], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen" | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const addDropDownItem = () => { } | ||
|
||
export const addImportForm = (syncFn: Function) => jest.fn(); | ||
|
||
export const getDateSetting = (): string => 'a'; | ||
|
||
export const getCSRFToken = (): string => "csrfToken"; | ||
|
||
export const getMALUsername = () => 'malUsername'; | ||
|
||
export const getAnilistUsername = () => 'anilistUsername'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const clear = () => console.log('clearing console'); | ||
export const error = (msg: string) => console.log('logging error', msg); | ||
export const info = (msg: string) => console.log('logging info', msg); | ||
export const addCountLog = (op: string, type: string, max: number) => console.log('creating count log for', op, type, max); | ||
export const updateCountLog = (op: string, type: string, ct: number) => console.log('updating count log for', op, type, ct); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const sleep = () => Promise.resolve(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
jest.mock('../src/Dom'); | ||
jest.mock('../src/Log'); | ||
jest.mock('../src/util'); | ||
import { syncType } from '../src/MAL'; | ||
import * as fetchMock from 'fetch-mock'; | ||
import { completedAnime, completedAnilistAnime } from '../__testutils__/testData'; | ||
|
||
// jest.useFakeTimers(); | ||
|
||
describe('Sync', () => { | ||
beforeAll(() => fetchMock.catch(500)); | ||
afterEach(() => fetchMock.restore()); | ||
it('should sync', async () => { | ||
fetchMock | ||
.mock(/.+load.json.+/, [completedAnime], { repeat: 1 }) | ||
.mock(/.+load.json.+/, []); | ||
try { | ||
await syncType('anime', [completedAnilistAnime], 'test', 'test'); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
console.log(fetchMock.calls()) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as fetch from 'node-fetch'; | ||
// @ts-ignore | ||
global.fetch = fetch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as Types from '../src/Types'; | ||
|
||
const createDate = (year = 0, month = 0, day = 0) => ({ year, month, day }); | ||
|
||
const baseMalItem = (): Types.BaseMALItem => ({ | ||
status: 0, | ||
csrf_token: 'csrfToken', | ||
score: 10, | ||
finish_date: createDate(), | ||
start_date: createDate(), | ||
}); | ||
|
||
export const completedAnime: Types.MALAnime = { | ||
...baseMalItem(), | ||
status: 2, | ||
anime_id: 1, | ||
num_watched_times: 1, | ||
num_watched_episodes: 12, | ||
}; | ||
|
||
export const completedAnilistAnime: Types.FormattedEntry = { | ||
status: 'COMPLETED', | ||
score: 10, | ||
progress: 12, | ||
progressVolumes: 0, | ||
startedAt: createDate(), | ||
completedAt: createDate(), | ||
repeat: 1, | ||
type: 'anime', | ||
id: 1, | ||
title: 'title', | ||
}; |
Oops, something went wrong.