-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add converter request options (#8)
- Loading branch information
1 parent
c493235
commit e721d05
Showing
4 changed files
with
184 additions
and
130 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
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 |
---|---|---|
@@ -1,79 +1,81 @@ | ||
import { | ||
WowLookupFetchRequest, | ||
WowLookupFetchResponse, | ||
WowUrlConverter, | ||
WowUrlConverterConfig, | ||
WowUrlConvertRequest, | ||
WowUrlConvertResponse, | ||
WowUrlRankingItem | ||
WowLookupFetchRequest, | ||
WowLookupFetchResponse, | ||
WowUrlConverter, | ||
WowUrlConverterConfig, | ||
WowUrlConvertRequest, | ||
WowUrlConvertResponse, | ||
WowUrlRankingItem, | ||
} from "."; | ||
|
||
describe('Fetcher interface tests', () => { | ||
test('Create request', () => { | ||
const req: WowLookupFetchRequest = { | ||
mappingSource: "github" | ||
}; | ||
expect(req).toBeDefined(); | ||
}); | ||
describe("Fetcher interface tests", () => { | ||
test("Create request", () => { | ||
const req: WowLookupFetchRequest = { | ||
mappingSource: "github", | ||
}; | ||
expect(req).toBeDefined(); | ||
}); | ||
|
||
test('Create response', () => { | ||
const res: WowLookupFetchResponse = { | ||
wowMapping: { | ||
'gh': 'https://github.com' | ||
} | ||
}; | ||
expect(res).toBeDefined(); | ||
}); | ||
test("Create response", () => { | ||
const res: WowLookupFetchResponse = { | ||
wowMapping: { | ||
gh: "https://github.com", | ||
}, | ||
}; | ||
expect(res).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('Converter interface tests', () => { | ||
test('Create request', () => { | ||
const req: WowUrlConvertRequest = { | ||
wowUrl: 'test_wow_url' | ||
}; | ||
expect(req).toBeDefined(); | ||
}); | ||
describe("Converter interface tests", () => { | ||
test("Create request", () => { | ||
const req: WowUrlConvertRequest = { | ||
wowUrl: "test_wow_url", | ||
}; | ||
expect(req).toBeDefined(); | ||
}); | ||
|
||
test('Create response', () => { | ||
// TODO(tianhaoz95): add another test to check | ||
// it should fail without searchRanking once the | ||
// field has become required. | ||
const res: WowUrlConvertResponse = { | ||
fullUrl: 'test_full_url', | ||
searchRanking: [] | ||
}; | ||
expect(res).toBeDefined(); | ||
}); | ||
test("Create response", () => { | ||
// TODO(tianhaoz95): add another test to check | ||
// it should fail without searchRanking once the | ||
// field has become required. | ||
const res: WowUrlConvertResponse = { | ||
fullUrl: "test_full_url", | ||
isMatch: true, | ||
postfix: "wowlink", | ||
searchRanking: [], | ||
}; | ||
expect(res).toBeDefined(); | ||
}); | ||
|
||
test('Create ranking item', () => { | ||
const rankingItem: WowUrlRankingItem = { | ||
wowUrl: 'test_wow_url', | ||
fullUrl: 'test_full_url', | ||
score: 0.6 | ||
}; | ||
expect(rankingItem).toBeDefined(); | ||
}); | ||
test("Create ranking item", () => { | ||
const rankingItem: WowUrlRankingItem = { | ||
wowUrl: "test_wow_url", | ||
fullUrl: "test_full_url", | ||
score: 0.6, | ||
}; | ||
expect(rankingItem).toBeDefined(); | ||
}); | ||
|
||
test('Create config', () => { | ||
const config: WowUrlConverterConfig = { | ||
fetcherResponse: { | ||
wowMapping: {} | ||
} | ||
}; | ||
expect(config).toBeDefined(); | ||
}); | ||
test("Create config", () => { | ||
const config: WowUrlConverterConfig = { | ||
fetcherResponse: { | ||
wowMapping: {}, | ||
}, | ||
}; | ||
expect(config).toBeDefined(); | ||
}); | ||
|
||
test('Create converter', () => { | ||
class DummyConverter implements WowUrlConverter { | ||
convert(req: WowUrlConvertRequest): WowUrlConvertResponse { | ||
const res: WowUrlConvertResponse = { | ||
fullUrl: 'test_full_url', | ||
searchRanking: [] | ||
}; | ||
return res; | ||
} | ||
test("Create converter", () => { | ||
class DummyConverter implements WowUrlConverter { | ||
convert(req: WowUrlConvertRequest): WowUrlConvertResponse { | ||
const res: WowUrlConvertResponse = { | ||
fullUrl: "test_full_url", | ||
searchRanking: [], | ||
}; | ||
const converter: WowUrlConverter = new DummyConverter(); | ||
expect(converter).toBeDefined(); | ||
}); | ||
return res; | ||
} | ||
} | ||
const converter: WowUrlConverter = new DummyConverter(); | ||
expect(converter).toBeDefined(); | ||
}); | ||
}); |
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