-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from SensCritique/feat/add-rating-disney
feat(provider): possibilité d'utiliser l'extension sur disney+ / les notes senscritique sont visible sur plus de produits
- Loading branch information
Showing
61 changed files
with
2,053 additions
and
840 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 |
---|---|---|
@@ -1,24 +1,39 @@ | ||
// eslint-disable-next-line no-undef | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2020: true, | ||
jest: true | ||
jest: true, | ||
}, | ||
globals: { | ||
chrome: true | ||
chrome: true, | ||
browser: true, | ||
}, | ||
extends: [ | ||
'standard' | ||
], | ||
parser: "@typescript-eslint/parser", | ||
plugins: [ | ||
'@typescript-eslint' | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'prettier'], | ||
parserOptions: { | ||
ecmaVersion: 11, | ||
sourceType: 'module' | ||
sourceType: 'module', | ||
}, | ||
rules: { | ||
"no-unused-vars": "off" | ||
} | ||
'no-unused-vars': 'error', | ||
'no-console': ['error', { allow: ['error'] }], | ||
semi: ['error', 'never'], | ||
'comma-dangle': 'off', | ||
'no-underscore-dangle': [2, { allowAfterThis: true }], | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
trailingComma: 'es5', | ||
singleQuote: true, | ||
semi: false, | ||
printWidth: 80, | ||
}, | ||
], | ||
}, | ||
} |
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
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,12 +1,12 @@ | ||
import { test, expect } from '@jest/globals' | ||
import RatingFactory from '../../src/dom/RatingFactory' | ||
import { Service } from '../../src/http/Service' | ||
import { Service } from '../../src/enum/Service' | ||
import { SensCritiqueRating } from '../../src/dom/SensCritiqueRating' | ||
|
||
test('It should create an SensCritiqueRating instance', () => { | ||
const sensCritiqueRating = (new RatingFactory()).create(Service.SENSCRITIQUE, { | ||
const sensCritiqueRating = new RatingFactory().create(Service.SENSCRITIQUE, { | ||
name: 'test', | ||
redirect: '' | ||
redirect: '', | ||
}) | ||
expect(sensCritiqueRating).toBeInstanceOf(SensCritiqueRating) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export default { | ||
firefox: { | ||
runtime: { | ||
onMessage: { | ||
addListener: jest.fn() | ||
}, | ||
}, | ||
tabs: { | ||
query: jest.fn(), | ||
sendMessage: jest.fn() | ||
} | ||
}, | ||
chrome: { | ||
runtime: { | ||
onMessage: { | ||
addListener: jest.fn() | ||
}, | ||
}, | ||
tabs: { | ||
query: jest.fn(), | ||
sendMessage: jest.fn() | ||
} | ||
} | ||
} |
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,74 @@ | ||
import { test, expect } from '@jest/globals' | ||
import browser from '../global/browser' | ||
Object.assign(global, browser) | ||
import { compare } from '../../src/helper/ComparatorHelper' | ||
import { | ||
matchByTitleAndYearDataset, | ||
matchByMovieAndYearDataset, | ||
matchYearAndSeasonIfTvShowDataset, | ||
matchByTitleAndSeasonIfTvShowDataset, | ||
notMatchByTypeOrProviderDataset, | ||
notMatchByTitleAndYearIfMovieDataset, | ||
notMatchByTitleYearAndSeasonsIfTvShowDataset, | ||
} from '../../src/dataset/CamparatorHelper' | ||
jest.mock('../../src/background') | ||
|
||
describe('Test products matching with compare()', () => { | ||
test.each(matchByTitleAndYearDataset)( | ||
'It should return video infos if title and year match', | ||
async (senscritiqueProduct, platformProduct, expectedVideoInfo) => { | ||
const videoInfo = await compare(senscritiqueProduct, platformProduct) | ||
expect(videoInfo).toEqual(expectedVideoInfo) | ||
} | ||
) | ||
|
||
test.each(matchByMovieAndYearDataset)( | ||
'It should return video infos if the product is a movie and year match', | ||
async (senscritiqueProduct, platformProduct, expectedVideoInfo) => { | ||
const videoInfo = await compare(senscritiqueProduct, platformProduct) | ||
expect(videoInfo).toEqual(expectedVideoInfo) | ||
} | ||
) | ||
|
||
test.each(matchYearAndSeasonIfTvShowDataset)( | ||
'It should return video infos if the product is a tvShow and year, season match', | ||
async (senscritiqueProduct, platformProduct, expectedVideoInfo) => { | ||
const videoInfo = await compare(senscritiqueProduct, platformProduct) | ||
expect(videoInfo).toEqual(expectedVideoInfo) | ||
} | ||
) | ||
|
||
test.each(matchByTitleAndSeasonIfTvShowDataset)( | ||
'It should return video infos if the product is a tvShow and title, season match', | ||
async (senscritiqueProduct, platformProduct, expectedVideoInfo) => { | ||
const videoInfo = await compare(senscritiqueProduct, platformProduct) | ||
expect(videoInfo).toEqual(expectedVideoInfo) | ||
} | ||
) | ||
}) | ||
|
||
describe('Test products does not match with compare()', () => { | ||
test.each(notMatchByTypeOrProviderDataset)( | ||
'It should return null if type or provider not match', | ||
async (senscritiqueProduct, platformProduct) => { | ||
const videoInfo = await compare(senscritiqueProduct, platformProduct) | ||
expect(videoInfo).toBeNull() | ||
} | ||
) | ||
|
||
test.each(notMatchByTitleAndYearIfMovieDataset)( | ||
'It should return null if the product is a movie but the title and year not match', | ||
async (senscritiqueProduct, platformProduct) => { | ||
const videoInfo = await compare(senscritiqueProduct, platformProduct) | ||
expect(videoInfo).toBeNull() | ||
} | ||
) | ||
|
||
test.each(notMatchByTitleYearAndSeasonsIfTvShowDataset)( | ||
'It should return null if the product is a tvShow but title, year and season not match', | ||
async (senscritiqueProduct, platformProduct) => { | ||
const videoInfo = await compare(senscritiqueProduct, platformProduct) | ||
expect(videoInfo).toBeNull() | ||
} | ||
) | ||
}) |
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,76 @@ | ||
import { | ||
levenshteinDistance, | ||
shortStringMatchedLevenshtein, | ||
longStringMatchedLevenshtein, | ||
matchedWithLevenshtein, | ||
} from '../../src/helper/LevenshteinHelper' | ||
import { test, expect } from '@jest/globals' | ||
|
||
describe('levenshteinDistance tests', () => { | ||
test('It should render 0', () => { | ||
expect(levenshteinDistance('mike', 'mike')).toBe(0) | ||
}) | ||
|
||
test('It should render 2', () => { | ||
expect(levenshteinDistance('mike ', 'mike 45')).toBe(2) | ||
}) | ||
|
||
test('It should render 3', () => { | ||
expect(levenshteinDistance('test test test', 'test test test 35')).toBe(3) | ||
}) | ||
}) | ||
|
||
describe('shortStringMatchedLevenshtein tests', () => { | ||
test('It should render true', () => { | ||
expect(shortStringMatchedLevenshtein('mike', 0)).toBeTruthy() | ||
}) | ||
|
||
test('It should render false', () => { | ||
expect(shortStringMatchedLevenshtein('mike 36', 3)).toBeFalsy() | ||
}) | ||
|
||
test('It should render false', () => { | ||
expect(shortStringMatchedLevenshtein('test test test', 5)).toBeFalsy() | ||
}) | ||
}) | ||
|
||
describe('longStringMatchedLevenshtein tests', () => { | ||
test('It should render false', () => { | ||
expect(longStringMatchedLevenshtein('mike', 0)).toBeFalsy() | ||
}) | ||
|
||
test('It should render false', () => { | ||
expect(longStringMatchedLevenshtein('mike 36', 3)).toBeFalsy() | ||
}) | ||
|
||
test('It should render false', () => { | ||
expect(longStringMatchedLevenshtein('test test test', 5)).toBeFalsy() | ||
}) | ||
|
||
test('It should render true', () => { | ||
expect(longStringMatchedLevenshtein('test test test', 4)).toBeTruthy() | ||
}) | ||
}) | ||
|
||
describe('matchedWithLevenshtein tests', () => { | ||
test('It should render false', () => { | ||
expect( | ||
matchedWithLevenshtein('Andor', 'Vader: A Star Wars Theory Fan Series') | ||
).toBeFalsy() | ||
}) | ||
test('It should render false', () => { | ||
expect(matchedWithLevenshtein('Andor', 'Andor')).toBeTruthy() | ||
}) | ||
test('It should render false', () => { | ||
expect(matchedWithLevenshtein('Andor', 'Andors')).toBeTruthy() | ||
}) | ||
test('It should render false', () => { | ||
expect(matchedWithLevenshtein('Andor', 'Andors 34')).toBeFalsy() | ||
}) | ||
test('It should render false', () => { | ||
expect(matchedWithLevenshtein('Andor', '')).toBeFalsy() | ||
}) | ||
test('It should render false', () => { | ||
expect(matchedWithLevenshtein('', 'Andor')).toBeFalsy() | ||
}) | ||
}) |
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,28 @@ | ||
import { matchedProviders } from '../../src/helper/ProviderHelper' | ||
|
||
const matchByProvider = [ | ||
[['Netflix'], ['netflix']], | ||
[['Netflix+', 'Disney'], ['netflix']], | ||
[['test_Netflix+', 'amazon'], ['netflix']], | ||
] | ||
|
||
const notMatchByProvider = [ | ||
[[''], ['netflix']], | ||
[['Disney'], ['netflix']], | ||
] | ||
|
||
describe('matchedProviders tests', () => { | ||
test.each(matchByProvider)( | ||
'It should be true', | ||
async (senscritiqueProviders, platformName) => { | ||
expect(matchedProviders(senscritiqueProviders, platformName)).toBeTruthy() | ||
} | ||
) | ||
|
||
test.each(notMatchByProvider)( | ||
'It should be false', | ||
async (senscritiqueProviders, platformName) => { | ||
expect(matchedProviders(senscritiqueProviders, platformName)).toBeFalsy() | ||
} | ||
) | ||
}) |
Oops, something went wrong.