Remove jest tests

I don't have time to maintain them
pull/1745/head
Chocobozzz 2019-03-13 16:07:40 +01:00 committed by Chocobozzz
parent 0b16f5f220
commit d0e1e32589
7 changed files with 1 additions and 149 deletions

View File

@ -45,7 +45,6 @@ matrix:
- env: TEST_SUITE=api-4
- env: TEST_SUITE=cli
- env: TEST_SUITE=lint
- env: TEST_SUITE=jest
script:
- NODE_PENDING_JOB_WAIT=1000 travis_retry npm run travis -- "$TEST_SUITE"

View File

@ -20,8 +20,7 @@
"postinstall": "npm rebuild node-sass",
"webpack-bundle-analyzer": "webpack-bundle-analyzer",
"webdriver-manager": "webdriver-manager",
"ngx-extractor": "ngx-extractor",
"test": "jest --no-cache"
"ngx-extractor": "ngx-extractor"
},
"license": "GPLv3",
"typings": "*.d.ts",
@ -31,38 +30,6 @@
"simple-get": "^2.8.1",
"punycode": "^1.4.1"
},
"jest": {
"globals": {
"ts-jest": {
"tsConfigFile": "<rootDir>/src/tsconfig.spec.json"
},
"__TRANSFORM_HTML__": true
},
"transform": {
"^.+\\.(ts|js|html)$": "<rootDir>/node_modules/jest-preset-angular/preprocessor.js"
},
"moduleNameMapper": {
"^@app/(.*)": "<rootDir>/src/app/$1",
"environments/(.*)": "<rootDir>/src/environments/$1"
},
"testMatch": [
"**/__tests__/**/*.+(ts|js)?(x)",
"**/+(*.)+(spec|test).+(ts|js)?(x)"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!lodash-es/)"
],
"preset": "jest-preset-angular",
"setupTestFrameworkScriptFile": "<rootDir>/src/setupJest.ts"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.1",
"@angular/animations": "~7.2.4",
@ -92,7 +59,6 @@
"@types/hls.js": "^0.12.0",
"@types/jasmine": "^2.8.7",
"@types/jasminewd2": "^2.0.3",
"@types/jest": "^23.3.1",
"@types/jschannel": "^1.0.0",
"@types/linkifyjs": "^2.1.1",
"@types/lodash-es": "^4.17.0",
@ -120,8 +86,6 @@
"https-browserify": "^1.0.0",
"jasmine-core": "^3.1.0",
"jasmine-spec-reporter": "^4.2.1",
"jest": "^23.5.0",
"jest-preset-angular": "^6.0.0",
"jschannel": "^1.0.2",
"karma": "^3.0.0",
"karma-chrome-launcher": "^2.2.0",
@ -153,7 +117,6 @@
"stream-browserify": "^2.0.1",
"stream-http": "^3.0.0",
"terser-webpack-plugin": "^1.1.0",
"ts-jest": "^23.1.4",
"tslint": "^5.7.0",
"tslint-config-standard": "^8.0.1",
"typescript": "3.2",

View File

@ -1,66 +0,0 @@
import { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service'
import { VideosProvider } from '@app/shared/video/video.service'
import { EMPTY, of } from 'rxjs'
import Mock = jest.Mock
describe('"Recent Videos" Recommender', () => {
describe('getRecommendations', () => {
let videosService: VideosProvider
let service: RecentVideosRecommendationService
let getVideosMock: Mock<any>
beforeEach(() => {
getVideosMock = jest.fn(() => EMPTY)
videosService = {
getVideos: getVideosMock
}
service = new RecentVideosRecommendationService(videosService)
})
it('should filter out the given UUID from the results', async (done) => {
const vids = [
{ uuid: 'uuid1' },
{ uuid: 'uuid2' }
]
getVideosMock.mockReturnValueOnce(of({ videos: vids }))
const result = await service.getRecommendations({ uuid: 'uuid1' }).toPromise()
const uuids = result.map(v => v.uuid)
expect(uuids).toEqual(['uuid2'])
done()
})
it('should return 5 results when the given UUID is NOT in the first 5 results', async (done) => {
const vids = [
{ uuid: 'uuid2' },
{ uuid: 'uuid3' },
{ uuid: 'uuid4' },
{ uuid: 'uuid5' },
{ uuid: 'uuid6' },
{ uuid: 'uuid7' }
]
getVideosMock.mockReturnValueOnce(of({ videos: vids }))
const result = await service.getRecommendations({ uuid: 'uuid1' }).toPromise()
expect(result.length).toEqual(5)
done()
})
it('should return 5 results when the given UUID IS PRESENT in the first 5 results', async (done) => {
const vids = [
{ uuid: 'uuid1' },
{ uuid: 'uuid2' },
{ uuid: 'uuid3' },
{ uuid: 'uuid4' },
{ uuid: 'uuid5' },
{ uuid: 'uuid6' }
]
getVideosMock
.mockReturnValueOnce(of({ videos: vids }))
const result = await service.getRecommendations({ uuid: 'uuid1' }).toPromise()
expect(result.length).toEqual(5)
done()
})
it('should fetch an extra result in case the given UUID is in the list', async (done) => {
await service.getRecommendations({ uuid: 'uuid1' }).toPromise()
let expectedSize = service.pageSize + 1
let params = { currentPage: jasmine.anything(), itemsPerPage: expectedSize }
expect(getVideosMock).toHaveBeenCalledWith(params, jasmine.anything())
done()
})
})
})

View File

@ -1,22 +0,0 @@
import { RecommendedVideosStore } from '@app/videos/recommendations/recommended-videos.store'
import { RecommendationService } from '@app/videos/recommendations/recommendations.service'
describe('RecommendedVideosStore', () => {
describe('requestNewRecommendations', () => {
let store: RecommendedVideosStore
let service: RecommendationService
beforeEach(() => {
service = {
getRecommendations: jest.fn(() => new Promise((r) => r()))
}
store = new RecommendedVideosStore(service)
})
it('should pull new videos from the service one time when given the same UUID twice', () => {
store.requestNewRecommendations('some-uuid')
store.requestNewRecommendations('some-uuid')
// Requests aren't fulfilled until someone asks for them (ie: subscribes)
store.recommendations$.subscribe()
expect(service.getRecommendations).toHaveBeenCalledTimes(1)
})
})
})

View File

@ -1 +0,0 @@
import 'jest-preset-angular';

View File

@ -1,17 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es5",
"baseUrl": "",
"allowJs": true
},
"files": [
"test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

View File

@ -36,8 +36,4 @@ elif [ "$1" = "lint" ]; then
( cd client
npm run lint
)
elif [ "$1" = "jest" ]; then
( cd client
npm run test
)
fi