From: Chocobozzz Date: Wed, 13 Mar 2019 15:07:40 +0000 (+0100) Subject: Remove jest tests X-Git-Tag: v1.3.0-rc.1~141 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=d0e1e32589f4e76446eb84a3ec8e7fea39963412;hp=0b16f5f2202e0c0832b5e678fadd95c64b8e8789;p=github%2FChocobozzz%2FPeerTube.git Remove jest tests I don't have time to maintain them --- diff --git a/.travis.yml b/.travis.yml index d252ae625..dcf7247b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/client/package.json b/client/package.json index 72708bd76..a8205a6b9 100644 --- a/client/package.json +++ b/client/package.json @@ -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": "/src/tsconfig.spec.json" - }, - "__TRANSFORM_HTML__": true - }, - "transform": { - "^.+\\.(ts|js|html)$": "/node_modules/jest-preset-angular/preprocessor.js" - }, - "moduleNameMapper": { - "^@app/(.*)": "/src/app/$1", - "environments/(.*)": "/src/environments/$1" - }, - "testMatch": [ - "**/__tests__/**/*.+(ts|js)?(x)", - "**/+(*.)+(spec|test).+(ts|js)?(x)" - ], - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "jsx", - "json", - "node" - ], - "transformIgnorePatterns": [ - "/node_modules/(?!lodash-es/)" - ], - "preset": "jest-preset-angular", - "setupTestFrameworkScriptFile": "/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", diff --git a/client/src/app/videos/recommendations/recent-videos-recommendation.service.spec.ts b/client/src/app/videos/recommendations/recent-videos-recommendation.service.spec.ts deleted file mode 100644 index 698b2e27b..000000000 --- a/client/src/app/videos/recommendations/recent-videos-recommendation.service.spec.ts +++ /dev/null @@ -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 - 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() - }) - }) -}) diff --git a/client/src/app/videos/recommendations/recommended-videos.store.spec.ts b/client/src/app/videos/recommendations/recommended-videos.store.spec.ts deleted file mode 100644 index e12a3f520..000000000 --- a/client/src/app/videos/recommendations/recommended-videos.store.spec.ts +++ /dev/null @@ -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) - }) - }) -}) diff --git a/client/src/setupJest.ts b/client/src/setupJest.ts deleted file mode 100644 index 8d88704e8..000000000 --- a/client/src/setupJest.ts +++ /dev/null @@ -1 +0,0 @@ -import 'jest-preset-angular'; diff --git a/client/src/tsconfig.spec.json b/client/src/tsconfig.spec.json deleted file mode 100644 index cefee1781..000000000 --- a/client/src/tsconfig.spec.json +++ /dev/null @@ -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" - ] -} diff --git a/scripts/travis.sh b/scripts/travis.sh index 509b40d87..3557816c8 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -36,8 +36,4 @@ elif [ "$1" = "lint" ]; then ( cd client npm run lint ) -elif [ "$1" = "jest" ]; then - ( cd client - npm run test - ) fi