-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Update Jest configuration for end-to-end tests and remove unuse…
…d test files
- Loading branch information
Showing
9 changed files
with
188 additions
and
16 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,3 +1,16 @@ | ||
{ | ||
"a-file-icon-vscode.activeIconPacks": ["nest", "rails"] | ||
"a-file-icon-vscode.activeIconPacks": [ | ||
"angular", | ||
"ngrx", | ||
"nest", | ||
"react", | ||
"redux", | ||
"recoil", | ||
"vue", | ||
"vuex", | ||
"rails", | ||
"phalcon", | ||
"volt", | ||
"none" | ||
] | ||
} |
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,12 @@ | ||
{ | ||
"moduleFileExtensions": ["js", "json", "ts"], | ||
"rootDir": "./", | ||
"testRegex": ".*\\.e2e-spec\\.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"moduleNameMapper": { | ||
"^src/(.*)$": "<rootDir>/src/$1" | ||
}, | ||
"testEnvironment": "node" | ||
} |
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 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import * as request from 'supertest'; | ||
import { AppModule } from './../src/app.module'; | ||
|
||
describe('Reciter E2E TESTS', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
|
||
app = moduleFixture.createNestApplication(); | ||
await app.init(); | ||
}); | ||
|
||
it('should get all reciters', () => { | ||
return request(app.getHttpServer()).get('/reciter').expect(200); | ||
}); | ||
|
||
it('should get reciter by id', () => { | ||
return request(app.getHttpServer()).get('/reciter/1').expect(200); | ||
}); | ||
|
||
it('should return 404 if reciter not found by id', () => { | ||
return request(app.getHttpServer()).get('/reciter/99999').expect(404); | ||
}); | ||
|
||
describe('adding image section', () => { | ||
it('should add an image to a reciter', () => { | ||
return request(app.getHttpServer()) | ||
.patch('/reciter/1') | ||
.send({ image: 'image-url' }) | ||
.expect(200); | ||
}); | ||
|
||
it('should return 404 if reciter not found by id', () => { | ||
return request(app.getHttpServer()) | ||
.patch('/reciter/99999') | ||
.send({ image: 'image-url' }) | ||
.expect(404); | ||
}); | ||
}); | ||
}); |
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,70 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import * as request from 'supertest'; | ||
import { AppModule } from './../src/app.module'; | ||
|
||
describe('Surah E2E TESTS', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
|
||
app = moduleFixture.createNestApplication(); | ||
await app.init(); | ||
}); | ||
|
||
it('should get list of all surah', () => { | ||
return request(app.getHttpServer()) | ||
.get('/surah') | ||
.expect(200) | ||
.expect((res) => { | ||
expect(res.body).toHaveLength(114); | ||
expect(res.body[0]).toMatchObject({ | ||
id: 1, | ||
name_arabic: 'الفاتحة', | ||
name_complex: 'Al-Fatihah', | ||
revelation_place: 'meccan', | ||
verses_count: 7, | ||
image: 'image-url', | ||
}); | ||
}); | ||
}); | ||
|
||
it('should get a surah by id', () => { | ||
return request(app.getHttpServer()) | ||
.get('/surah/1') | ||
.expect(200) | ||
.expect((res) => { | ||
expect(res.body).toMatchObject({ | ||
id: 1, | ||
name_arabic: 'الفاتحة', | ||
name_complex: 'Al-Fatihah', | ||
revelation_place: 'meccan', | ||
verses_count: 7, | ||
image: 'image-url', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('adding image section', () => { | ||
it('should add an image to a surah', () => { | ||
return request(app.getHttpServer()) | ||
.patch('/surah/1') | ||
.send({ image: 'image-url' }) | ||
.expect(200); | ||
}); | ||
|
||
it('should return 404 if surah not found by id', () => { | ||
return request(app.getHttpServer()) | ||
.patch('/surah/150') | ||
.send({ image: 'image-url' }) | ||
.expect(404); | ||
}); | ||
}); | ||
|
||
it('should return 404 if surah not found by id', () => { | ||
return request(app.getHttpServer()).get('/surah/150').expect(404); | ||
}); | ||
}); |
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,33 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import * as request from 'supertest'; | ||
import { AppModule } from './../src/app.module'; | ||
|
||
describe('Verse E2E TESTS', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
|
||
app = moduleFixture.createNestApplication(); | ||
await app.init(); | ||
}); | ||
|
||
it('should get surah verses', () => { | ||
return request(app.getHttpServer()) | ||
.get('/verse/surah?surah_id=1') | ||
.expect(200) | ||
.expect((res) => { | ||
expect(res.body.verses).toHaveLength(7); | ||
expect(res.body.verses[0]).toMatchObject({ | ||
id: 1, | ||
vers: 'بِسۡمِ ٱللَّهِ ٱلرَّحۡمَٰنِ ٱلرَّحِيمِ', | ||
verse_number: 1, | ||
vers_lang: 'ar', | ||
surah_id: 1, | ||
}); | ||
}); | ||
}); | ||
}); |
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