- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP * Replace ava with jest in core * Update package-lock * Exclude tests from transpilation * Expect transformPluginFile to throw * Mock fetch in audius tests * Mock fetch in audius tests
- v0.6.42
- v0.6.41
- v0.6.40
- v0.6.39
- v0.6.38
- v0.6.37
- v0.6.36
- v0.6.35
- v0.6.34
- v0.6.33
- v0.6.32
- v0.6.31
- v0.6.30
- v0.6.29
- v0.6.28
- v0.6.27
- v0.6.26
- v0.6.25
- v0.6.24
- v0.6.23
- v0.6.22
- v0.6.21
- v0.6.20
- v0.6.19
- v0.6.18
- v0.6.17
- v0.6.16
- v0.6.15
- v0.6.14
- v0.6.13
- v0.6.12
- nightly
- latest
- fd06a3
- f5ec0d
- f2f59d
- eac584
- e94388
- e8fcb6
- e8d6cc
- c9cb81
- bc8b7b
- b6e5b2
- b2a752
- ${GITHUB_SHA}
- 52769a
- 9545bf
- 8988ba
- 549e4d
- 0437ae
- 268b26
- 95cfe0
- 58dfc7
- 27f5b2a
- 23bcaf
- 15c5eb
- 9f77fc
- 3f9007
- 2f1ec0
- 2ec701
- 2dd909
- 2c7b60
- 2a872a
Showing
22 changed files
with
4,785 additions
and
3,068 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,9 @@ | ||
class Electron { | ||
prototype = {} | ||
get() { | ||
return ''; | ||
} | ||
set() {} | ||
} | ||
|
||
module.exports = Electron; |
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,6 @@ | ||
class MockLogger { | ||
static log() {} | ||
static error() {} | ||
} | ||
|
||
module.exports = MockLogger; |
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,17 @@ | ||
module.exports = { | ||
app: { | ||
getPath: () => { } | ||
}, | ||
remote: { | ||
transformSource: () => { }, | ||
app: { | ||
getPath: () => { } | ||
}, | ||
dialog: { | ||
showOpenDialog: jest.fn(async () => Promise.resolve({ | ||
canceled: false, | ||
filePaths: ['test file.txt'] | ||
})) | ||
} | ||
} | ||
}; |
File renamed without changes.
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,7 @@ | ||
|
||
export default async () => ({ | ||
transform: { | ||
'^.+\\.(ts|tsx)$': 'ts-jest', | ||
'^.+\\.(js|jsx)$': 'ts-jest' | ||
} | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,30 @@ | ||
import path from 'path'; | ||
|
||
import { transformSource, transformPluginFile } from '..'; | ||
|
||
describe('Plugin tests', () => { | ||
it('transform a simple plugin', async () => { | ||
const result: any = await transformPluginFile(path.resolve(__dirname, 'testData/simple.js')); | ||
expect(() => eval(result.code)).not.toThrow(); | ||
}); | ||
|
||
it('throw an error when a nonexistent path is provided', async () => { | ||
expect(transformPluginFile('test')).rejects.toThrow(); | ||
}); | ||
|
||
it('transform some code', async () => { | ||
const result: any = await transformSource('const f = (a,b) => a+b; const test = f(2,3); export default test;'); | ||
expect(eval(result.code)).toEqual(5); | ||
}); | ||
|
||
it('throw an error on invalid code', async () => { | ||
expect(transformSource('()asd')).rejects.toThrow(); | ||
}); | ||
|
||
it('transform jsx', async () => { | ||
const result: any = await transformSource( | ||
'import React from \'react\'; export const component = () => <div />;' | ||
); | ||
expect(() => eval(result.code)).not.toThrow(); | ||
}); | ||
}); |
File renamed without changes.
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,43 @@ | ||
import _ from 'lodash'; | ||
import { rest } from '..'; | ||
|
||
const mockFetch = (data) => { | ||
global.fetch = jest.fn(() => | ||
Promise.resolve({ | ||
json: jest.fn(() => ({ | ||
data | ||
})) | ||
}) | ||
) as any; | ||
}; | ||
|
||
|
||
describe('Audius tests', () => { | ||
beforeEach(() => { | ||
_.invoke(fetch, 'resetMocks'); | ||
}); | ||
|
||
it('audius host is selected', async () => { | ||
mockFetch(['1', '2', '3']); | ||
const endpoint = await rest.Audius._findHost(); | ||
expect(endpoint.length > 0).toBe(true); | ||
}); | ||
|
||
it('search artists', async () => { | ||
mockFetch('test'); | ||
const endpoint = await rest.Audius._findHost(); | ||
mockFetch([{ test: 'test data' }]); | ||
const response = await rest.Audius.artistSearch(endpoint, 'roto'); | ||
const json = await response.json(); | ||
expect(json.data).toEqual([{ test: 'test data'}]); | ||
}); | ||
|
||
it('search tracks', async () => { | ||
mockFetch('test'); | ||
const endpoint = await rest.Audius._findHost(); | ||
mockFetch([{ test: 'test data' }]); | ||
const response = await rest.Audius.trackSearch(endpoint, 'roto'); | ||
const json = await response.json(); | ||
expect(json.data).toEqual([{ test: 'test data'}]); | ||
}); | ||
}); |
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,27 @@ | ||
import 'isomorphic-fetch'; | ||
import { Bandcamp } from '.'; | ||
|
||
describe('Bandcamp tests', () => { | ||
it('search', async () => { | ||
const result = await Bandcamp.search('swans'); | ||
expect(result.length > 0).toBe(true); | ||
}); | ||
|
||
it('get album info', async () => { | ||
const result = await Bandcamp.getAlbumInfo('https://swans.bandcamp.com/album/the-seer'); | ||
expect(result.tracks.length === 11).toBe(true); | ||
expect(result.artist).toBe('SWANS'); | ||
expect(result.title).toBe('The Seer'); | ||
expect(result.imageUrl).toBe('https://f4.bcbits.com/img/a3233794906_2.jpg'); | ||
expect(result.url).toBe('https://swans.bandcamp.com/album/the-seer'); | ||
}); | ||
|
||
it('get track stream', async () => { | ||
const { duration, stream } = await Bandcamp.getTrackData('https://swans.bandcamp.com/track/apostate'); | ||
expect(stream.length).toBeGreaterThan(0); | ||
expect(stream.includes('https')).toBe(true); | ||
expect(stream.includes('stream')).toBe(true); | ||
expect(stream.includes('mp3-128')).toBe(true); | ||
expect(duration).toBeGreaterThan(0); | ||
}); | ||
}); |
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,54 @@ | ||
import { rest } from '..'; | ||
|
||
const setupLastFmApi = (key: string, secret: string): rest.LastFmApi => { | ||
return new rest.LastFmApi(key, secret); | ||
}; | ||
|
||
describe('Last.fm tests', () => { | ||
it('add api key to url', () => { | ||
const api = setupLastFmApi('test', 'test'); | ||
const url = 'http://example.com?test=test1&test2=test3'; | ||
const withKey = api.addApiKey(url); | ||
|
||
expect(withKey).toBe('http://example.com?test=test1&test2=test3&api_key=test'); | ||
}); | ||
|
||
it('sign url', () => { | ||
const api = setupLastFmApi('test', 'test'); | ||
const url = 'http://example.com?test=test1&test2=test3'; | ||
const signed = api.sign(url); | ||
|
||
expect(signed).toBe('4dd7efc68ff9d7c293ac0f71eb133ace'); | ||
}); | ||
|
||
it('prepare url', () => { | ||
const api = setupLastFmApi('test', 'test'); | ||
const url = 'http://example.com?test=test1&test2=test3'; | ||
const prepared = api.prepareUrl(url); | ||
|
||
expect(prepared).toBe('http://example.com?test=test1&test2=test3&api_key=test&api_sig=cd28b8fd248073c89aad9b77dd069567'); | ||
}); | ||
|
||
it('get top tracks', async () => { | ||
const api = setupLastFmApi('2b75dcb291e2b0c9a2c994aca522ac14', | ||
'2ee49e35f08b837d43b2824198171fc8'); | ||
|
||
const response = await api.getTopTracks(); | ||
const data = await response.json(); | ||
|
||
expect(typeof data.tracks).toBe('object'); | ||
expect(data.tracks.track instanceof Array).toBe(true); | ||
}); | ||
|
||
it('search tracks', async () => { | ||
const api = setupLastFmApi('2b75dcb291e2b0c9a2c994aca522ac14', | ||
'2ee49e35f08b837d43b2824198171fc8'); | ||
|
||
const response = await api.searchTracks('billie jean'); | ||
const data = await response.json(); | ||
|
||
expect(typeof data.results).toBe('object'); | ||
expect(data.results.trackmatches.track instanceof Array).toBe(true); | ||
expect(data.results.trackmatches.track.length).toBeGreaterThan(0); | ||
}); | ||
}); |
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,45 @@ | ||
import { rest } from '..'; | ||
import { OriginalSegment } from './SponsorBlock.types'; | ||
|
||
import { MockServer, VIDEO_ID } from '../../__mocks__/sponsor-block-server'; | ||
|
||
describe('Sponsorblock tests', () => { | ||
it('has empty result', () => { | ||
const segments = rest.SponsorBlock.formatResponse(MockServer.request(VIDEO_ID.HAS_NO_SEGMENT) as OriginalSegment[]); | ||
expect(segments.length).toBe(0); | ||
}); | ||
|
||
it('has result', () => { | ||
const segments = rest.SponsorBlock.formatResponse(MockServer.request(VIDEO_ID.HAS_SEGMENT) as OriginalSegment[]); | ||
expect(segments instanceof Array).toBe(true); | ||
expect(segments.length).toBeGreaterThan(0); | ||
}); | ||
|
||
it('result is ascendingly ordered by startTime', () => { | ||
const segments = rest.SponsorBlock.formatResponse(MockServer.request(VIDEO_ID.HAS_SEGMENT_NOT_ORDER) as OriginalSegment[]); | ||
expect(segments instanceof Array).toBe(true); | ||
expect(segments.every( | ||
(segment, i, arr) => !i || (segment.startTime > arr[i - 1].startTime))).toBe(true); | ||
}); | ||
|
||
it('result has no segment contained in other segment ', () => { | ||
const segments = rest.SponsorBlock.formatResponse(MockServer.request(VIDEO_ID.HAS_SEGMENT_CONTAIN_OTHER_SEGMENT) as OriginalSegment[]); | ||
expect(segments instanceof Array).toBe(true); | ||
expect(segments.every( | ||
(segment, i, arr) => { | ||
for (let j = 0; j < arr.length; j += 1) { | ||
if (j === i) { | ||
continue; | ||
} | ||
// check whether this segment is contained in another segment | ||
// j------i--------i-----j | ||
// start start end end | ||
if (arr[j].startTime <= segment.startTime && | ||
arr[j].endTime >= segment.endTime) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
})).toBe(true); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -16,7 +16,8 @@ | |
}, | ||
"include": [ | ||
"src", | ||
"typings" | ||
"typings", | ||
"test" | ||
], | ||
"exclude": [ | ||
"lib" | ||
|
Oops, something went wrong.
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
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